Images¶
Manage images on the server.
Methods available on client.images
:
Image objects¶
- class Image¶
An image on the server.
- attrs¶
The raw representation of this object from the server.
- id¶
The ID of the object.
- labels¶
The labels of an image as dictionary.
- short_id¶
The ID of the image truncated to 12 characters, plus the
sha256:
prefix.
- tags¶
The image’s tags.
- history()¶
Show the history of an image.
- Returns:
The history of the image.
- Return type:
(list)
- Raises:
docker.errors.APIError – If the server returns an error.
- reload()¶
Load this object from the server again and update
attrs
with the new data.
- save(chunk_size=2097152, named=False)¶
Get a tarball of an image. Similar to the
docker save
command.- Parameters:
chunk_size (int) – The generator will return up to that much data per iteration, but may return less. If
None
, data will be streamed as it is received. Default: 2 MBnamed (str or bool) – If
False
(default), the tarball will not retain repository and tag information for this image. If set toTrue
, the first tag in thetags
list will be used to identify the image. Alternatively, any element of thetags
list can be used as an argument to use that specific tag as the saved identifier.
- Returns:
A stream of raw archive data.
- Return type:
(generator)
- Raises:
docker.errors.APIError – If the server returns an error.
Example
>>> image = cli.images.get("busybox:latest") >>> f = open('/tmp/busybox-latest.tar', 'wb') >>> for chunk in image.save(): >>> f.write(chunk) >>> f.close()
- tag(repository, tag=None, **kwargs)¶
Tag this image into a repository. Similar to the
docker tag
command.- Parameters:
repository (str) – The repository to set for the tag
tag (str) – The tag name
force (bool) – Force
- Raises:
docker.errors.APIError – If the server returns an error.
- Returns:
True
if successful- Return type:
(bool)
RegistryData objects¶
- class RegistryData¶
Image metadata stored on the registry, including available platforms.
- attrs¶
The raw representation of this object from the server.
- id¶
The ID of the object.
- short_id¶
The ID of the image truncated to 12 characters, plus the
sha256:
prefix.
- has_platform(platform)¶
Check whether the given platform identifier is available for this digest.
- Parameters:
platform (str or dict) – A string using the
os[/arch[/variant]]
format, or a platform dictionary.- Returns:
True
if the platform is recognized as available,False
otherwise.- Return type:
(bool)
- Raises:
docker.errors.InvalidArgument – If the platform argument is not a valid descriptor.
- pull(platform=None)¶
Pull the image digest.
- Parameters:
platform (str) – The platform to pull the image for.
Default –
None
- Returns:
A reference to the pulled image.
- Return type:
(
Image
)
- reload()¶
Load this object from the server again and update
attrs
with the new data.