Images API Reference

Images

class apolo_sdk.Images

Docker image subsystem.

Used for pushing docker images onto Apolo docker registry for later usage by Jobs.run() and pulling these images back to local docker.

async push(local: LocalImage, remote: RemoteImage | None = None, *, progress: AbstractDockerImageProgress | None = None) RemoteImage[source]

Push local docker image to remote side.

Parameters:
  • local (LocalImage) – a spec of local docker image (e.g. created by docker build) for pushing on Apolo Registry.

  • remote (RemoteImage) – a spec for remote image on Apolo Registry. Calculated from local image automatically if None (default).

  • progress (AbstractDockerImageProgress) – a callback interface for reporting pushing progress, None for no progress report (default).

Returns:

remote image if explicitly specified, calculated remote image if remote is None (RemoteImage)

async pull(remote: Optional[RemoteImage] = None, local: LocalImage, *, progress: Optional[AbstractDockerImageProgress] = None) RemoteImage[source]

Pull remote image from Apolo registry to local docker side.

Parameters:
  • remote (RemoteImage) – a spec for remote image on Apolo registry.

  • local (LocalImage) – a spec of local docker image to pull. Calculated from remote image automatically if None (default).

  • progress (AbstractDockerImageProgress) – a callback interface for reporting pulling progress, None for no progress report (default).

Returns:

local image if explicitly specified, calculated remote image if local is None (LocalImage)

async digest(image: RemoteImage) str[source]

Get digest of an image in Apolo registry.

Parameters:

image (RemoteImage) – a spec for remote image on Apolo registry.

Returns:

string representing image digest

async rm(image: RemoteImage, digest: str) str[source]

Delete remote image specified by given reference and digest from Apolo registry.

Parameters:
  • image (RemoteImage) – a spec for remote image on Apolo registry.

  • digest (str) – remote image digest, which can be obtained via digest method.

async list(cluster_name: str | None = None) List[RemoteImage][source]

List images on Apolo registry available to the user.

Parameters:

cluster_name (str) –

name of the cluster.

None means the current cluster (default).

Returns:

list of remote images not including tags (List[RemoteImage])

async tags(image: RemoteImage) List[RemoteImage][source]

List image references with tags for the specified remote image.

Parameters:

image (RemoteImage) – a spec for remote image without tag on Apolo registry.

Returns:

list of remote images with tags (List[RemoteImage])

async size(image: RemoteImage) int[source]

Return image size.

Parameters:

image (RemoteImage) – a spec for remote image with tag on Apolo registry.

Returns:

remote image size in bytes

async tag_info(image: RemoteImage) Tag[source]

Return info about specified tag.

Parameters:

image (RemoteImage) – a spec for remote image with tag on Apolo registry.

Returns:

tag information (name and size) (Tag)

AbstractDockerImageProgress

class apolo_sdk.AbstractDockerImageProgress

Base class for image operations progress, e.g. Images.pull() and Images.push(). Inherited from abc.ABC.

pull(data: ImageProgressPull) None[source]

Pulling image from remote Apolo registry to local Docker is started.

Parameters:

data (ImageProgressPull) – additional data, e.g. local and remote image objects.

push(data: ImageProgressPush) None[source]

Pushing image from local Docker to remote Apolo registry is started.

Parameters:

data (ImageProgressPush) – additional data, e.g. local and remote image objects.

step(data: ImageProgressStep) None[source]

Next step in image transfer is performed.

Parameters:

data (ImageProgressStep) – additional data, e.g. image layer id and progress report.

ImageProgressPull

class apolo_sdk.ImageProgressPull

Read-only dataclass for pulling operation report.

src

Source image, RemoteImage instance.

dst

Destination image, LocalImage instance.

class apolo_sdk.ImageProgressPush

Read-only dataclass for pulling operation report.

src

Source image, LocalImage instance.

dst

Destination image, RemoteImage instance.

class apolo_sdk.ImageProgressStep

Read-only dataclass for push/pull progress step.

layer_id

Image layer, str.

message

Progress message, str.

LocalImage

class apolo_sdk.LocalImage

Read-only dataclass for describing image in local Docker system.

name

Image name, str.

tag

Image tag (str), None if the tag is omitted (implicit latest tag).

RemoteImage

class apolo_sdk.RemoteImage

Read-only dataclass for describing image in remote registry (Apolo Platform hosted or other registries like DockerHub).

name

Image name, str.

tag

Image tag (str), None if the tag is omitted (implicit latest tag).

owner

User name (str) of a person who manages this image.

Public DockerHub images (e.g. "ubuntu:latest") have no owner, the attribute is None.

org_name

Name (str) of an organization who manages this image or None if there is no such org.

Public DockerHub images (e.g. "ubuntu:latest") have no org, the attribute is None.

registry

Host name for images hosted on Apolo Registry (str), None for other registries like DockerHub.

as_docker_url(with_scheme: bool = False) str[source]

URL that can be used to reference this image with Docker.

Parameters:

with_scheme (bool) – if set to True, returned URL includes scheme (https://), otherwise (default behavior) - scheme is omitted.

with_tag(tag: bool) RemoteImage

Creates a new reference to remote image with tag.

Parameters:

tag (str) – new tag

Returns:

remote image with tag

classmethod new_platform_image(name: str, registry: str, *, owner: str, cluster_name: str, tag: str | None = None) RemoteImage[source]

Create a new instance referring to an image hosted on Apolo Platform.

Parameters:
  • name (str) – name of the image

  • registry (str) – registry where the image is located

  • owner (str) – image owner name

  • cluster_name (str) – name of the cluster

  • tag (str) – image tag

classmethod new_external_image(name: str, registry: str | None = None, *, tag: str | None = None) RemoteImage[source]

Create a new instance referring to an image hosted on an external registry (e.g. DockerHub).

Parameters:
  • name (str) – name of the image

  • registry (str) – registry where the image is located

  • tag (str) – image tag

class apolo_sdk.Tag

Read-only dataclass for tag information.

name

Tag name, str.

size

Tag size in bytes, int.