clibdocker  0.1.0-alpha.0
A Docker API for C
Data Structures | Macros | Typedefs | Functions
docker_images.h File Reference

Docker Images API. More...

#include <coll_arraylist.h>
#include "docker_connection_util.h"
#include "docker_result.h"
#include "docker_util.h"
Include dependency graph for docker_images.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  docker_progress_detail_t
 Provides progress detail for docker image creation process. More...
 
struct  docker_image_create_status_t
 Docker Image Creation Status is returned when creating a docker image. It is useful for a user facing application to show creation progress. More...
 
struct  docker_build_status_t
 Docker Build Status is used to provide a status update of the docker image build status. More...
 

Macros

#define DEFAULT_DOCKER_FILE_NAME   "Dockerfile"
 Default Dockerfile name.
 
#define docker_image_id_get(img)   get_attr_str((json_object*)img, "Id")
 get the docker image id More...
 
#define docker_image_container_get(img)   get_attr_str((json_object*)img, "Container")
 get the docker image container name More...
 
#define docker_image_comment_get(img)   get_attr_str((json_object*)img, "Comment")
 get the docker image comment More...
 
#define docker_image_os_get(img)   get_attr_str((json_object*)img, "Os")
 get the docker image operating system More...
 
#define docker_image_architecture_get(img)   get_attr_str((json_object*)img, "Architecture")
 get the docker image architecture More...
 
#define docker_image_parent_get(img)   get_attr_str((json_object*)img, "Parent")
 get the docker image parent image name More...
 
#define docker_image_docker_version_get(img)   get_attr_str((json_object*)img, "DockerVersion")
 get the docker version of the docker image More...
 
#define docker_image_virtual_size_get(img)   get_attr_long_long((json_object*)img, "VirtualSize")
 get the virtual size of the docker image More...
 
#define docker_image_size_get(img)   get_attr_long_long((json_object*)img, "Size")
 get the size of the docker image More...
 
#define docker_image_author_get(img)   get_attr_str((json_object*)img, "Author")
 get the author of the docker image More...
 
#define docker_image_created_get(img)   get_attr_unsigned_long((json_object*)img, "Created")
 get the created datetime of the docker image More...
 
#define docker_image_repo_tags_get(img)   get_attr_json_object((json_object*)img, "RepoTags")
 get the docker image repo tags More...
 
#define docker_image_repo_tags_length(img)   json_object_array_length(docker_image_repo_tags_get(img))
 get the length of the repo tags array for the given docker image More...
 
#define docker_image_repo_tags_get_idx(img, i)   (char*)json_object_get_string(json_object_array_get_idx(docker_image_repo_tags_get(img), i))
 get the ith element of the repo tags array for the given docker image More...
 
#define docker_image_repo_digests_get(img)   get_attr_json_object((json_object*)img, "RepoDigests")
 get the docker image repo digests More...
 
#define docker_image_repo_digests_length(img)   json_object_array_length(docker_image_repo_digests_get(img))
 get the length of the repo digests array for the given docker image More...
 
#define docker_image_repo_digests_get_idx(img, i)   (char*)json_object_get_string(json_object_array_get_idx(docker_image_repo_digests_get(img), i))
 get the ith element of the repo digests array for the given docker image More...
 
#define free_docker_image_list(image_ls)   json_object_put(image_ls)
 Free the docker image list object. More...
 
#define docker_image_list_length(image_ls)   json_object_array_length(image_ls)
 Get the list of the docker image list. More...
 
#define docker_image_list_get_idx(image_ls, i)   (docker_image*) json_object_array_get_idx(image_ls, i)
 Get the image at index i from the image list. More...
 

Typedefs

typedef json_object docker_image
 The Docker Image object. More...
 
typedef json_object docker_image_list
 Docker Image List object. More...
 
typedef struct docker_progress_detail_t docker_progress_detail
 Provides progress detail for docker image creation process.
 
typedef struct docker_image_create_status_t docker_image_create_status
 Docker Image Creation Status is returned when creating a docker image. It is useful for a user facing application to show creation progress.
 
typedef struct docker_build_status_t docker_build_status
 Docker Build Status is used to provide a status update of the docker image build status.
 

Functions

d_err_t docker_images_list (docker_context *ctx, docker_image_list **images, int all, int digests, char *filter_before, int filter_dangling, char *filter_label, char *filter_reference, char *filter_since)
 
d_err_t docker_image_create_from_image (docker_context *ctx, char *from_image, char *tag, char *platform)
 
d_err_t docker_image_create_from_image_cb (docker_context *ctx, void(*status_cb)(docker_image_create_status *, void *cbargs), void *cbargs, char *from_image, char *tag, char *platform)
 
d_err_t docker_image_build_cb (docker_context *ctx, char *folder, char *dockerfile, void(*status_cb)(docker_build_status *, void *cbargs), void *cbargs,...)
 

Detailed Description

Docker Images API.

Macro Definition Documentation

◆ docker_image_architecture_get

#define docker_image_architecture_get (   img)    get_attr_str((json_object*)img, "Architecture")

get the docker image architecture

Parameters
imgdocker image
Returns
char* architecture

◆ docker_image_author_get

#define docker_image_author_get (   img)    get_attr_str((json_object*)img, "Author")

get the author of the docker image

Parameters
imgdocker image
Returns
char* author

◆ docker_image_comment_get

#define docker_image_comment_get (   img)    get_attr_str((json_object*)img, "Comment")

get the docker image comment

Parameters
imgdocker image
Returns
char* comment text

◆ docker_image_container_get

#define docker_image_container_get (   img)    get_attr_str((json_object*)img, "Container")

get the docker image container name

Parameters
imgdocker image
Returns
char* container

◆ docker_image_created_get

#define docker_image_created_get (   img)    get_attr_unsigned_long((json_object*)img, "Created")

get the created datetime of the docker image

Parameters
imgdocker image
Returns
unsigned long created datetime (epoch)

◆ docker_image_docker_version_get

#define docker_image_docker_version_get (   img)    get_attr_str((json_object*)img, "DockerVersion")

get the docker version of the docker image

Parameters
imgdocker image
Returns
char* docker version

◆ docker_image_id_get

#define docker_image_id_get (   img)    get_attr_str((json_object*)img, "Id")

get the docker image id

Parameters
imgdocker image
Returns
char* docker image id

◆ docker_image_list_get_idx

#define docker_image_list_get_idx (   image_ls,
 
)    (docker_image*) json_object_array_get_idx(image_ls, i)

Get the image at index i from the image list.

Parameters
image_lsimage list
iindex
Returns
docker_image image object

◆ docker_image_list_length

#define docker_image_list_length (   image_ls)    json_object_array_length(image_ls)

Get the list of the docker image list.

Parameters
image_lsimage list
Returns
int image list length

◆ docker_image_os_get

#define docker_image_os_get (   img)    get_attr_str((json_object*)img, "Os")

get the docker image operating system

Parameters
imgdocker image
Returns
char* operating system

◆ docker_image_parent_get

#define docker_image_parent_get (   img)    get_attr_str((json_object*)img, "Parent")

get the docker image parent image name

Parameters
imgdocker image
Returns
char* parent

◆ docker_image_repo_digests_get

#define docker_image_repo_digests_get (   img)    get_attr_json_object((json_object*)img, "RepoDigests")

get the docker image repo digests

Use the docker_image_repo_digests_length and docker_image_repo_digests_get_idx to get the individual repo digests.

Parameters
imgdocker image
Returns
json_object* repo digests

◆ docker_image_repo_digests_get_idx

#define docker_image_repo_digests_get_idx (   img,
 
)    (char*)json_object_get_string(json_object_array_get_idx(docker_image_repo_digests_get(img), i))

get the ith element of the repo digests array for the given docker image

Parameters
imgdocker image
iindex
Returns
char* ith repo digest

◆ docker_image_repo_digests_length

#define docker_image_repo_digests_length (   img)    json_object_array_length(docker_image_repo_digests_get(img))

get the length of the repo digests array for the given docker image

Parameters
imgdocker image
Returns
int length of the repo digests array

◆ docker_image_repo_tags_get

#define docker_image_repo_tags_get (   img)    get_attr_json_object((json_object*)img, "RepoTags")

get the docker image repo tags

Use the docker_image_repo_tags_length and docker_image_repo_tags_get_idx to get the individual repo tags.

Parameters
imgdocker image
Returns
json_object* repo tags

◆ docker_image_repo_tags_get_idx

#define docker_image_repo_tags_get_idx (   img,
 
)    (char*)json_object_get_string(json_object_array_get_idx(docker_image_repo_tags_get(img), i))

get the ith element of the repo tags array for the given docker image

Parameters
imgdocker image
iindex
Returns
char* ith repo tag

◆ docker_image_repo_tags_length

#define docker_image_repo_tags_length (   img)    json_object_array_length(docker_image_repo_tags_get(img))

get the length of the repo tags array for the given docker image

Parameters
imgdocker image
Returns
int length of the repo tags array

◆ docker_image_size_get

#define docker_image_size_get (   img)    get_attr_long_long((json_object*)img, "Size")

get the size of the docker image

Parameters
imgdocker image
Returns
long long size

◆ docker_image_virtual_size_get

#define docker_image_virtual_size_get (   img)    get_attr_long_long((json_object*)img, "VirtualSize")

get the virtual size of the docker image

Parameters
imgdocker image
Returns
long long virtual size

◆ free_docker_image_list

#define free_docker_image_list (   image_ls)    json_object_put(image_ls)

Free the docker image list object.

Parameters
image_lslist

Typedef Documentation

◆ docker_image

typedef json_object docker_image

The Docker Image object.

Represents a docker image object returned in the Docker images API call results. Depending on result, some or all values maybe unavailable.

Use the getters defined in this API to access the members of the Docker Image object.

All getters are of the form docker_image_<member>_get For example, to get the id of the image use docker_image_id_get(img)

◆ docker_image_list

typedef json_object docker_image_list

Docker Image List object.

This is internally represented as a json array object, which was parsed from a Docker Image API call response.

Function Documentation

◆ docker_image_build_cb()

d_err_t docker_image_build_cb ( docker_context ctx,
char *  folder,
char *  dockerfile,
void(*)(docker_build_status *, void *cbargs)  status_cb,
void *  cbargs,
  ... 
)

see https://docs.docker.com/engine/api/v1.39/#operation/ImageBuild Build a new image from the files in a folder, with a progress callback

Parameters
ctxdocker context
folderthe folder containing the docker image build files (if NULL, default is current directory)
dockerfilename of the dockerfile. (If NULL, default "Dockerfile" is assumed)
status_cbcallback to call for updates
cbargscallback args for the upate call
...options to the build command
Returns
error code.

References make_docker_call(), and docker_context_t::url.

◆ docker_image_create_from_image()

d_err_t docker_image_create_from_image ( docker_context ctx,
char *  from_image,
char *  tag,
char *  platform 
)

see https://docs.docker.com/engine/api/v1.39/#operation/ImageCreate Create a new image by pulling image:tag for platform

Parameters
ctxdocker context
from_imageimage name
tagwhich tag to pull, for e.g. "latest"
platformwhich platform to pull the image for (format os[/arch[/variant]]), default is ""
Returns
error code.

References docker_image_create_from_image_cb().

◆ docker_image_create_from_image_cb()

d_err_t docker_image_create_from_image_cb ( docker_context ctx,
void(*)(docker_image_create_status *, void *cbargs)  status_cb,
void *  cbargs,
char *  from_image,
char *  tag,
char *  platform 
)

see https://docs.docker.com/engine/api/v1.39/#operation/ImageCreate Create a new image by pulling image:tag for platform, with a progress callback

Parameters
ctxdocker context
status_cbcallback to call for updates
cbargscallback args for the upate call
from_imageimage name
tagwhich tag to pull, for e.g. "latest"
platformwhich platform to pull the image for (format os[/arch[/variant]]), default is ""
Returns
error code.

Referenced by docker_image_create_from_image().

◆ docker_images_list()

d_err_t docker_images_list ( docker_context ctx,
docker_image_list **  images,
int  all,
int  digests,
char *  filter_before,
int  filter_dangling,
char *  filter_label,
char *  filter_reference,
char *  filter_since 
)

List images matching the filters.

Parameters
ctxdocker context
imageslist of images to be returned
all(0 indicates false, true otherwise)
digestsadd repo digests in return object (0 is false, true otherwise)
filter_before<image-name>[:<tag>], <image id> or <image@digest>
filter_dangling0 is false, true otherwise.
filter_labellabel=key or label="key=value" of an image label
filter_reference<image-name>[:<tag>]
filter_since<image-name>[:<tag>], <image id> or <image@digest>
Returns
error code

References make_docker_call(), and docker_context_t::url.