images_manager

PodmanResource manager subclassed for Images.

class ImagesManager(client: APIClient = None)[source]

Bases: BuildMixin, Manager

Specialized Manager for Image resources.

Initialize Manager() object.

Parameters:

client – APIClient() configured to connect to Podman service.

build(**kwargs) Tuple[Image, Iterator[bytes]]

Returns built image.

Keyword Arguments:
  • path (str) –

  • Dockerfile. (fileobj – A file object to use as the) –

  • tag (str) –

  • quiet (bool) –

  • nocache (bool) –

  • rm (bool) –

  • timeout (int) –

  • custom_context (bool) – Optional if using fileobj (ignored) –

  • encoding (str) – The encoding for a stream. Set to gzip for compressing (ignored) –

  • pull (bool) –

  • forcerm (bool) –

  • dockerfile (str) –

  • buildargs (Mapping[str,str) –

  • container_limits (Dict[str, Union[int,str]]) –

    A dictionary of limits applied to each container created by the build process.

    Valid keys:

    • memory (int): set memory limit for build

    • memswap (int): Total memory (memory + swap), -1 to disable swap

    • cpushares (int): CPU shares (relative weight)

    • cpusetcpus (str): CPUs in which to allow execution, For example, “0-3”, “0,1”

    • cpuperiod (int): CPU CFS (Completely Fair Scheduler) period (Podman only)

    • cpuquota (int): CPU CFS (Completely Fair Scheduler) quota (Podman only)

  • shmsize (int) – If omitted the system uses 64MB

  • labels (Mapping[str,str]) –

  • cache_from (List[str]) –

  • target (str) –

  • network_mode (str) –

  • squash (bool) –

  • extra_hosts (Dict[str,str]) – containers, as a mapping of hostname to IP address.

  • platform (str) –

  • isolation (str) – Isolation technology used during build. (ignored) –

  • use_config_proxy (bool) (ignored) –

  • http_proxy (bool) - Inject http proxy environment variables into container (Podman only) –

  • layers (bool) –

  • output (str) –

  • outputformat (str) –

Returns:

first item is the podman.domain.images.Image built

second item is the build logs

Raises:
  • BuildError – when there is an error during the build

  • APIError – when service returns an error

  • TypeError – when neither path nor fileobj is not specified

exists(key: str) bool[source]

Return true when image exists.

get(name: str) Image[source]

Returns an image by name or id.

Parameters:

name – Image id or name for which to search

Raises:
  • ImageNotFound – when image does not exist

  • APIError – when service returns an error

get_registry_data(name: str, auth_config=typing.Mapping[str, str]) RegistryData[source]

Returns registry data for an image.

Provided for compatibility

Parameters:
  • name – Image name

  • auth_config – Override configured credentials. Keys username and password are required.

Raises:

APIError – when service returns an error

list(**kwargs) List[Image][source]

Report on images.

Keyword Arguments:
  • name (str) –

  • all (bool) –

  • filters (Mapping[str, Union[str, List[str]]) –

    Available filters:

    • dangling (bool)

    • label (Union[str, List[str]]): format either “key” or “key=value”

Raises:

APIError – when service returns an error

load(data: bytes) Generator[Image, None, None][source]

Restore an image previously saved.

Parameters:

data – Image to be loaded in tarball format.

Raises:

APIError – when service returns an error

prepare_model(attrs: PodmanResource | Mapping[str, Any]) PodmanResourceType

Create a model from a set of attributes.

prune(filters: Mapping[str, Any] | None = None) Dict[Literal['ImagesDeleted', 'SpaceReclaimed'], Any][source]

Delete unused images.

The Untagged keys will always be “”.

Parameters:

filters

Qualify Images to prune. Available filters:

  • dangling (bool): when true, only delete unused and untagged images.

  • until (str): Delete images older than this timestamp.

Raises:

APIError – when service returns an error

prune_builds() Dict[Literal['CachesDeleted', 'SpaceReclaimed'], Any][source]

Delete builder cache.

Method included to complete API, the operation always returns empty

CacheDeleted and zero SpaceReclaimed.

pull(repository: str, tag: str | None = None, all_tags: bool = False, **kwargs) Image | List[Image] | Iterator[str][source]

Request Podman service to pull image(s) from repository.

Parameters:
  • repository – Repository to pull from

  • tag – Image tag to pull. Default: “latest”.

  • all_tags – pull all image tags from repository.

Keyword Arguments:
  • auth_config (Mapping[str, str]) – config for this request. auth_config should contain the username and password keys to be valid.

  • platform (str) –

  • progress_bar (bool) – the compat endpoint). Default: False

  • tls_verify (bool) – True.

  • stream (bool) – Default: False.

Returns:

When stream is True, return a generator publishing the service pull progress. If all_tags is True, return list of Image’s rather than Image pulled.

Raises:

APIError – when service returns an error

push(repository: str, tag: str | None = None, **kwargs) str | Iterator[str | Dict[str, Any]][source]

Push Image or repository to the registry.

Parameters:
  • repository – Target repository for push

  • tag – Tag to push, if given

Keyword Arguments:
  • str] (auth_config (Mapping[str,) – Override configured credentials. Must include username and password keys.

  • decode (bool) – return data from server as Dict[str, Any]. Ignored unless stream=True.

  • destination (str) – alternate destination for image. (Podman only)

  • stream (bool) – return output as blocking generator. Default: False.

  • tlsVerify (bool) – Require TLS verification.

Raises:

APIError – when service returns an error

remove(image: Image | str, force: bool | None = None, noprune: bool = False) List[Dict[Literal['Deleted', 'Untagged', 'Errors', 'ExitCode'], str | int]][source]

Delete image from Podman service.

Parameters:
  • image – Name or Id of Image to remove

  • force – Delete Image even if in use

  • noprune – Ignored.

Raises:
  • ImageNotFound – when image does not exist

  • APIError – when service returns an error

scp(source: str, dest: str | None = None, quiet: bool | None = False) str[source]

Securely copy images between hosts.

Parameters:
  • source – source connection/image

  • dest – destination connection/image

  • quiet – do not print save/load output, only the image

Returns:

A string containing the loaded image

Raises:

APIError – when service returns an error

search(term: str, **kwargs) List[Dict[str, Any]][source]

Search Images on registries.

Parameters:

term – Used to target Image results.

Keyword Arguments:
  • filters (Mapping[str, List[str]) –

    Refine results of search. Available filters:

    • is-automated (bool): Image build is automated.

    • is-official (bool): Image build is owned by product provider.

    • stars (int): Image has at least this number of stars.

  • noTrunc (bool) – Do not truncate any result string. Default: True.

  • limit (int) – Maximum number of results.

  • listTags (bool) – list the available tags in the repository. Default: False

Raises:

APIError – when service returns an error

property resource

prepare_model() will create Image classes.

Type:

Type[podman.domain.images.Image]