Skip to content

Manage container images

The CRUD methods are used to read, update, and delete container images. They can be called directly from the SDK or through a Project object. When using a Project object, omit the project parameter and pass every other parameter as a keyword argument. For image creation, see Create a container image.

Read

Use the read methods to retrieve container images from the backend or load them from a YAML descriptor.

get_containerimage

Get a container image entity from the backend.

Parameters:

Name Type Description Default
identifier str

Entity name or entity key (store://<project>/<entity_type>/<kind>/<(name>:)<uuid>).

required
project str

Project name. Required when identifier is an entity name.

None
entity_id str

Entity identifier. If omitted, the latest version is returned.

None

Returns:

Type Description
Containerimage

Retrieved container image entity.

Examples:

Get the latest version by name and project:

import digitalhub as dh

image = dh.get_containerimage("my-image", project="my-project")

Get a specific version by key:

image = dh.get_containerimage(
    "store://my-project/containerimage/container-image/my-image:123e4567-e89b-42d3-a456-426614174000",
)
get_containerimage_versions

Get all versions of a container image entity from the backend.

Parameters:

Name Type Description Default
identifier str

Entity name or entity key (store://<project>/<entity_type>/<kind>/<(name>:)<uuid>).

required
project str

Project name. Required when identifier is an entity name.

None

Returns:

Type Description
list[Containerimage]

All versions of the container image entity.

Examples:

Get all versions by name and project:

import digitalhub as dh

images = dh.get_containerimage_versions("my-image", project="my-project")

Get all versions of the image referenced by its key:

images = dh.get_containerimage_versions(
    "store://my-project/containerimage/container-image/my-image:123e4567-e89b-42d3-a456-426614174000",
)
list_containerimages

List container image entities in a project.

Parameters:

Name Type Description Default
project str

Project name.

required
q str

Query string used to filter entities.

None
name str

Entity name used to filter results.

None
kind str

Entity kind used to filter results.

None
labels list[str]

Labels used to filter results.

None
user str

User who created the entity.

None
state str

Entity state used to filter results.

None
created str

Creation date filter.

None
updated str

Update date filter.

None
versions str

Version filter. Defaults to the latest version.

None

Returns:

Type Description
list[Containerimage]

Container image entities matching the filters.

Examples:

List container images in a project:

import digitalhub as dh

images = dh.list_containerimages(project="my-project")
import_containerimage

Import a container image entity from a YAML file or entity key.

Parameters:

Name Type Description Default
file str

Path to a YAML file containing the entity descriptor. Provide either file or key.

None
key str

Entity key (store://<project>/<entity_type>/<kind>/<(name>:)<uuid>). Provide either file or key.

None
reset_id bool

Whether to generate a new entity identifier instead of preserving the identifier from the imported entity.

False
context str

Project name used for context resolution. If omitted, the project from the entity descriptor is used.

None

Returns:

Type Description
Containerimage

Imported container image entity.

Examples:

Import an entity from a YAML file:

import digitalhub as dh

image = dh.import_containerimage("my-image.yaml")
load_containerimage

Load a container image entity from a YAML file.

Parameters:

Name Type Description Default
file str

Path to a YAML file containing the entity descriptor.

required

Returns:

Type Description
Containerimage

Loaded container image entity. An existing entity is updated when it can be identified; otherwise, a new entity is created.

Examples:

Load an entity from a YAML file:

import digitalhub as dh

image = dh.load_containerimage("my-image.yaml")

Update

Update a container image after changing its mutable metadata.

update_containerimage

Update a container image entity in the backend.

Parameters:

Name Type Description Default
entity Containerimage

Entity to update. The entity specification is immutable.

required

Returns:

Type Description
Containerimage

Updated container image entity.

Examples:

Update the description of an existing entity:

import digitalhub as dh

image = dh.get_containerimage("my-image", project="my-project")
image.set_description("Updated image")
image = dh.update_containerimage(image)

Delete

Delete one container image version or all versions of an image.

delete_containerimage

Delete one or more versions of a container image entity from the backend.

Parameters:

Name Type Description Default
identifier str

Entity name or entity key (store://<project>/<entity_type>/<kind>/<(name>:)<uuid>). Use an entity name when delete_all_versions is True.

required
project str

Project name. Required when identifier is an entity name.

None
entity_id str

Identifier of the version to delete. Required when delete_all_versions is False and identifier does not contain the version identifier.

None
delete_all_versions bool

Whether to delete all versions of the named entity. When False, only one version is deleted.

False
cascade bool

Whether to request cascade deletion from the backend.

True

Returns:

Type Description
dict

Response data from the backend.

Examples:

Delete one version by key:

import digitalhub as dh

dh.delete_containerimage(
    "store://my-project/containerimage/container-image/my-image:123e4567-e89b-42d3-a456-426614174000",
)

Delete one version by name and project:

dh.delete_containerimage(
    "my-image",
    project="my-project",
    entity_id="123e4567-e89b-42d3-a456-426614174000",
)

Delete all versions by name:

dh.delete_containerimage(
    "my-image",
    project="my-project",
    delete_all_versions=True,
)