images¶
Model and Manager for Image resources.
- class Image(attrs: Mapping[str, Any] | None = None, client: APIClient | None = None, collection: Manager | None = None, podman_client: PodmanClient | None = None)[source]¶
Bases:
PodmanResourceDetails and configuration for an Image managed by the Podman service.
Initialize base class for PodmanResource’s.
- Parameters:
attrs – Mapping of attributes for resource from Podman service.
client – Configured connection to a Podman service.
collection – Manager of this category of resource, named collection for compatibility
podman_client – PodmanClient() configured to connect to Podman object.
- history() list[dict[str, Any]][source]¶
Returns history of the Image.
- Raises:
APIError – when service returns an error
- reload(**kwargs) None¶
Refresh this object’s data from the service.
- Keyword Arguments:
compatible (bool) – Use Docker compatibility endpoint
- remove(**kwargs) list[dict[Literal['Deleted', 'Untagged', 'Errors', 'ExitCode'], str | int]][source]¶
Delete image from Podman service.
Podman only
- Keyword Arguments:
force – Delete Image even if in use
noprune – Ignored.
- Returns:
Report on which images were deleted and untagged, including any reported errors.
- Raises:
ImageNotFound – when image does not exist
APIError – when service returns an error
- save(chunk_size: int | None = 2097152, named: str | bool = False) Iterator[bytes][source]¶
Returns Image as tarball.
Format is set to docker-archive, this allows load() to import this tarball.
- Parameters:
chunk_size – If None, data will be streamed in received buffer size. If not None, data will be returned in sized buffers. Default: 2MB
named (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 thetagslist will be used to identify the image. Alternatively, any element of thetagslist can be used as an argument to use that specific tag as the saved identifier.
- Raises:
APIError – When service returns an error
InvalidArgument – When the provided Tag name is not valid for the image.
- tag(repository: str, tag: str | None, force: bool = False) bool[source]¶
Tag Image into repository.
- Parameters:
repository – The repository for tagging Image.
tag – optional tag name.
force – Ignore client errors
- Returns:
True, when operational succeeds.
- Raises:
ImageNotFound – when service cannot find image
APIError – when service returns an error
- property id¶
Returns the identifier for the object.
- Type:
str
- property labels¶
Return labels associated with Image.
- Type:
dict[str, str]
- manager: ImagesManager¶
- property short_id¶
Returns truncated identifier. ‘sha256’ preserved when included in the id.
No attempt is made to ensure the returned value is semantically meaningful for all resources.
- Type:
str
- property tags¶
Return tags from Image.
- Type:
list[str]