images_manager¶
PodmanResource manager subclassed for Images.
- class ImagesManager(client: APIClient | None = None, podman_client: PodmanClient | None = None)[source]¶
Bases:
BuildMixin,ManagerSpecialized Manager for Image resources.
Initialize Manager() object.
- Parameters:
client – APIClient() configured to connect to Podman service.
podman_client – PodmanClient() configured to connect to Podman object.
- 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)
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
- 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=collections.abc.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 | None = None, file_path: PathLike | None = None) Generator[Image, None, None][source]¶
Restore an image previously saved.
- Parameters:
data – Image to be loaded in tarball format.
file_path – Path of the Tarball. It works with both str and Path-like objects
- Raises:
APIError – When service returns an error.
PodmanError – When the arguments are not set correctly.
- prepare_model(attrs: PodmanResource | Mapping[str, Any]) PodmanResourceType¶
Create a model from a set of attributes.
- prune(all: bool | None = False, external: bool | None = False, filters: Mapping[str, Any] | None = None) dict[Literal['ImagesDeleted', 'SpaceReclaimed'], Any][source]¶
Delete unused images.
The Untagged keys will always be “”.
- Parameters:
all – Remove all images not in use by containers, not just dangling ones.
external – Remove images even when they are used by external containers
(e.g
containers). (by build)
filters –
Qualify Images to prune. Available filters:
dangling (bool): when true, only delete unused and untagged images.
- label: (dict): filter by label.
Examples: filters={“label”: {“key”: “value”}} filters={“label!”: {“key”: “value”}}
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.
compatMode (bool) – Default: True.
decode (bool) – Only applies with
stream=Trueplatform (str)
policy (str) - Pull policy. "always" (default)
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.
format (str) – Manifest type (oci, v2s1, or v2s2) to use when pushing an image. Default is manifest type of source, with fallbacks.
- 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: