View Source DockerEngineAPI.Api.Image (docker_engine_api v1.43.0)
API calls for all endpoints tagged Image
.
Summary
Functions
Delete builder cache
Build an image Build an image from a tar archive with a `Dockerfile` in it. The `Dockerfile` specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the `dockerfile` parameter. See the `Dockerfile` reference for more information. The Docker daemon performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output. The build is canceled if the client drops the connection by quitting or being killed.
Create a new image from a container
Create an image Create an image by either pulling it from a registry or importing it.
Remove an image Remove an image, along with any untagged parent images that were referenced by that image. Images can't be removed if they have descendant images, are being used by a running container or are being used by a build.
Export an image Get a tarball containing all images and metadata for a repository. If `name` is a specific name and tag (e.g. `ubuntu:latest`), then only that image (and its parents) are returned. If `name` is an image ID, similarly only that image (and its parents) are returned, but with the exclusion of the `repositories` file in the tarball, as there were no image names referenced. ### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: - `VERSION`: currently `1.0` - the file format version - `json`: detailed layer information, similar to `docker inspect layer_id` - `layer.tar`: A tarfile containing the filesystem changes in this layer The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories for storing attribute changes and deletions. If the tarball defines a repository, the tarball should also include a `repositories` file at the root that contains a list of repository and tag names mapped to layer IDs. ```json { "hello-world": { "latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1" } } ```
Export several images Get a tarball containing all images and metadata for several image repositories. For each value of the `names` parameter: if it is a specific name and tag (e.g. `ubuntu:latest`), then only that image (and its parents) are returned; if it is an image ID, similarly only that image (and its parents) are returned and there would be no names referenced in the 'repositories' file for this image ID. For details on the format, see the export image endpoint.
Get the history of an image Return parent layers of an image.
Inspect an image Return low-level information about an image.
List Images Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
Import images Load a set of images and tags into a repository. For details on the format, see the export image endpoint.
Delete unused images
Push an image Push an image to a registry. If you wish to push an image on to a private registry, that image must already have a tag which references the registry. For example, `registry.example.com/myimage:latest`. The push is cancelled if the HTTP connection is closed.
Search images Search for an image on Docker Hub.
Tag an image Tag an image so that it becomes part of a repository.
Functions
Delete builder cache
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :keep_storage (integer()): Amount of disk space in bytes to keep for cache
- :all (boolean()): Remove all types of build cache
- :filters (String.t): A JSON encoded value of the filters (a `map[string][]string`) to process on the list of build cache objects. Available filters: - `until=<timestamp>` remove cache older than `<timestamp>`. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon's local time. - `id=<id>` - `parent=<id>` - `type=<string>` - `description=<string>` - `inuse` - `shared` - `private`
Returns
} on success {:error, info} on failure
Build an image Build an image from a tar archive with a `Dockerfile` in it. The `Dockerfile` specifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying the `dockerfile` parameter. See the `Dockerfile` reference for more information. The Docker daemon performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output. The build is canceled if the client drops the connection by quitting or being killed.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :input_stream (binary()): A tar archive compressed with one of the following algorithms: identity (no compression), gzip, bzip2, xz.
- :dockerfile (String.t): Path within the build context to the `Dockerfile`. This is ignored if `remote` is specified and points to an external `Dockerfile`.
- :t (String.t): A name and optional tag to apply to the image in the `name:tag` format. If you omit the tag the default `latest` value is assumed. You can provide several `t` parameters.
- :extrahosts (String.t): Extra hosts to add to /etc/hosts
- :remote (String.t): A Git repository URI or HTTP/HTTPS context URI. If the URI points to a single text file, the file’s contents are placed into a file called `Dockerfile` and the image is built from that file. If the URI points to a tarball, the file is downloaded by the daemon and the contents therein used as the context for the build. If the URI points to a tarball and the `dockerfile` parameter is also specified, there must be a file with the corresponding path inside the tarball.
- :q (boolean()): Suppress verbose build output.
- :nocache (boolean()): Do not use the cache when building the image.
- :cachefrom (String.t): JSON array of images used for build cache resolution.
- :pull (String.t): Attempt to pull the image even if an older image exists locally.
- :rm (boolean()): Remove intermediate containers after a successful build.
- :forcerm (boolean()): Always remove intermediate containers, even upon failure.
- :memory (integer()): Set memory limit for build.
- :memswap (integer()): Total memory (memory + swap). Set as `-1` to disable swap.
- :cpushares (integer()): CPU shares (relative weight).
- :cpusetcpus (String.t): CPUs in which to allow execution (e.g., `0-3`, `0,1`).
- :cpuperiod (integer()): The length of a CPU period in microseconds.
- :cpuquota (integer()): Microseconds of CPU time that the container can get in a CPU period.
- :buildargs (String.t): JSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the buildargs as the environment context for commands run via the `Dockerfile` RUN instruction, or for variable expansion in other `Dockerfile` instructions. This is not meant for passing secret values. For example, the build arg `FOO=bar` would become `{"FOO":"bar"}` in JSON. This would result in the query parameter `buildargs={"FOO":"bar"}`. Note that `{"FOO":"bar"}` should be URI component encoded. Read more about the buildargs instruction.
- :shmsize (integer()): Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB.
- :squash (boolean()): Squash the resulting images layers into a single layer. (Experimental release only.)
- :labels (String.t): Arbitrary key/value labels to set on the image, as a JSON map of string pairs.
- :networkmode (String.t): Sets the networking mode for the run commands during build. Supported standard values are: `bridge`, `host`, `none`, and `container:<name|id>`. Any other value is taken as a custom network's name or ID to which this container should connect to.
- :content_type (String.t):
- :x_registry_config (String.t): This is a base64-encoded JSON object with auth configurations for multiple registries that a build may refer to. The key is a registry URL, and the value is an auth configuration object, as described in the authentication section. For example: ``` { "docker.example.com": { "username": "janedoe", "password": "hunter2" }, "https://index.docker.io/v1/": { "username": "mobydock", "password": "conta1n3rize14" } } ``` Only the registry domain name (and port if not the default 443) are required. However, for legacy reasons, the Docker Hub registry must be specified with both a `https://` prefix and a `/v1/` suffix even though Docker will prefer to use the v2 registry API.
- :platform (String.t): Platform in the format os[/arch[/variant]]
- :target (String.t): Target build stage
- :outputs (String.t): BuildKit output configuration
Returns
} on success {:error, info} on failure
Create a new image from a container
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :container_config (ContainerConfig): The container configuration
- :container (String.t): The ID or name of the container to commit
- :repo (String.t): Repository name for the created image
- :tag (String.t): Tag name for the create image
- :comment (String.t): Commit message
- :author (String.t): Author of the image (e.g., `John Hannibal Smith <hannibal@a-team.com>`)
- :pause (boolean()): Whether to pause the container before committing
- :changes (String.t): `Dockerfile` instructions to apply while committing
Returns
} on success {:error, info} on failure
Create an image Create an image by either pulling it from a registry or importing it.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :from_image (String.t): Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed.
- :from_src (String.t): Source to import. The value may be a URL from which the image can be retrieved or `-` to read the image from the request body. This parameter may only be used when importing an image.
- :repo (String.t): Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image.
- :tag (String.t): Tag or digest. If empty when pulling an image, this causes all tags for the given image to be pulled.
- :message (String.t): Set commit message for imported image.
- :input_image (String.t): Image content if the value `-` has been specified in fromSrc query parameter
- :x_registry_auth (String.t): A base64url-encoded auth configuration. Refer to the authentication section for details.
- :changes ([String.t]): Apply `Dockerfile` instructions to the image that is created, for example: `changes=ENV DEBUG=true`. Note that `ENV DEBUG=true` should be URI component encoded. Supported `Dockerfile` instructions: `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
- :platform (String.t): Platform in the format os[/arch[/variant]]. When used in combination with the `fromImage` option, the daemon checks if the given image is present in the local image cache with the given OS and Architecture, and otherwise attempts to pull the image. If the option is not set, the host's native OS and Architecture are used. If the given image does not exist in the local image cache, the daemon attempts to pull the image with the host's native OS and Architecture. If the given image does exists in the local image cache, but its OS or architecture does not match, a warning is produced. When used with the `fromSrc` option to import an image from an archive, this option sets the platform information for the imported image. If the option is not set, the host's native OS and Architecture are used for the imported image.
Returns
} on success {:error, info} on failure
Remove an image Remove an image, along with any untagged parent images that were referenced by that image. Images can't be removed if they have descendant images, are being used by a running container or are being used by a build.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- name (String.t): Image name or ID
- opts (KeywordList): [optional] Optional parameters
- :force (boolean()): Remove the image even if it is being used by stopped containers or has other tags
- :noprune (boolean()): Do not delete untagged parent images
Returns
, ...]} on success {:error, info} on failure
Export an image Get a tarball containing all images and metadata for a repository. If `name` is a specific name and tag (e.g. `ubuntu:latest`), then only that image (and its parents) are returned. If `name` is an image ID, similarly only that image (and its parents) are returned, but with the exclusion of the `repositories` file in the tarball, as there were no image names referenced. ### Image tarball format An image tarball contains one directory per image layer (named using its long ID), each containing these files: - `VERSION`: currently `1.0` - the file format version - `json`: detailed layer information, similar to `docker inspect layer_id` - `layer.tar`: A tarfile containing the filesystem changes in this layer The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories for storing attribute changes and deletions. If the tarball defines a repository, the tarball should also include a `repositories` file at the root that contains a list of repository and tag names mapped to layer IDs. ```json { "hello-world": { "latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1" } } ```
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- name (String.t): Image name or ID
- opts (KeywordList): [optional] Optional parameters
Returns
} on success {:error, info} on failure
Export several images Get a tarball containing all images and metadata for several image repositories. For each value of the `names` parameter: if it is a specific name and tag (e.g. `ubuntu:latest`), then only that image (and its parents) are returned; if it is an image ID, similarly only that image (and its parents) are returned and there would be no names referenced in the 'repositories' file for this image ID. For details on the format, see the export image endpoint.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :names ([String.t]): Image names to filter by
Returns
} on success {:error, info} on failure
Get the history of an image Return parent layers of an image.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- name (String.t): Image name or ID
- opts (KeywordList): [optional] Optional parameters
Returns
, ...]} on success {:error, info} on failure
Inspect an image Return low-level information about an image.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- name (String.t): Image name or id
- opts (KeywordList): [optional] Optional parameters
Returns
} on success {:error, info} on failure
List Images Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :all (boolean()): Show all images. Only images from a final layer (no children) are shown by default.
- :filters (String.t): A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters: - `before`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) - `dangling=true` - `label=key` or `label="key=value"` of an image label - `reference`=(`<image-name>[:<tag>]`) - `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`)
- :shared_size (boolean()): Compute and show shared size as a `SharedSize` field on each image.
- :digests (boolean()): Show digest information as a `RepoDigests` field on each image.
Returns
, ...]} on success {:error, info} on failure
Import images Load a set of images and tags into a repository. For details on the format, see the export image endpoint.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :images_tarball (binary()): Tar archive containing images
- :quiet (boolean()): Suppress progress details during load.
Returns
} on success {:error, info} on failure
Delete unused images
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :filters (String.t): Filters to process on the prune list, encoded as JSON (a `map[string][]string`). Available filters: - `dangling=<boolean>` When set to `true` (or `1`), prune only unused and untagged images. When set to `false` (or `0`), all unused images are pruned. - `until=<string>` Prune images created before this timestamp. The `<timestamp>` can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed relative to the daemon machine’s time. - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune images with (or without, in case `label!=...` is used) the specified labels.
Returns
} on success {:error, info} on failure
Push an image Push an image to a registry. If you wish to push an image on to a private registry, that image must already have a tag which references the registry. For example, `registry.example.com/myimage:latest`. The push is cancelled if the HTTP connection is closed.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- name (String.t): Image name or ID.
- x_registry_auth (String.t): A base64url-encoded auth configuration. Refer to the authentication section for details.
- opts (KeywordList): [optional] Optional parameters
- :tag (String.t): The tag to associate with the image on the registry.
Returns
} on success {:error, info} on failure
Search images Search for an image on Docker Hub.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- term (String.t): Term to search
- opts (KeywordList): [optional] Optional parameters
- :limit (integer()): Maximum number of results to return
- :filters (String.t): A JSON encoded value of the filters (a `map[string][]string`) to process on the images list. Available filters: - `is-automated=(true|false)` - `is-official=(true|false)` - `stars=<number>` Matches images that has at least 'number' stars.
Returns
, ...]} on success {:error, info} on failure
Tag an image Tag an image so that it becomes part of a repository.
Parameters
- connection (DockerEngineAPI.Connection): Connection to server
- name (String.t): Image name or ID to tag.
- opts (KeywordList): [optional] Optional parameters
- :repo (String.t): The repository to tag in. For example, `someuser/someimage`.
- :tag (String.t): The name of the new tag.
Returns
} on success {:error, info} on failure