Container Engines
zenml.container_engines
Client-side container engines (Docker, Podman).
Attributes
__all__ = ['ContainerEngine', 'DockerContainerEngine', 'PodmanContainerEngine', 'get_container_engine', 'check_container_engine']
module-attribute
Classes
ContainerEngine
Bases: ABC
Client-side abstraction over Docker/Podman (build, tag, push, inspect).
Implementations encapsulate OCI client details; callers use the factory
functions in :mod:zenml.container_engines.factory for the active engine.
Attributes
engine_type: ContainerEngineType
abstractmethod
property
The type of the container engine.
Returns:
| Type | Description |
|---|---|
ContainerEngineType
|
The type of the container engine. |
Functions
build(image_name: str, build_context: BuildContext, docker_build_options: Optional[DockerBuildOptions] = None, container_registry: Optional[BaseContainerRegistry] = None, **kwargs: Any) -> None
abstractmethod
Build an image locally from a tarball build context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Target image reference including tag. |
required |
build_context
|
BuildContext
|
Archive and Dockerfile content for the build. |
required |
docker_build_options
|
Optional[DockerBuildOptions]
|
Optional Docker-compatible build options. |
None
|
container_registry
|
Optional[BaseContainerRegistry]
|
When set, registry credentials are applied for authenticated base-image pulls during the build. |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the build fails (implementation-specific). |
Source code in src/zenml/container_engines/base.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
check_availability() -> Tuple[bool, str | None]
abstractmethod
Check whether this engine is installed and accessible and return the error message if not.
Returns:
| Type | Description |
|---|---|
bool
|
|
str | None
|
|
Source code in src/zenml/container_engines/base.py
50 51 52 53 54 55 56 57 | |
get_image_repo_digest(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> Optional[str]
abstractmethod
Resolve the repository digest for an image when the client can.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference (may include tag). |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
When set and the name matches the registry, credentials from this component are used for registry access. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Repo digest string (e.g. |
Optional[str]
|
|
Source code in src/zenml/container_engines/base.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
is_image_local(image_name: str) -> bool
abstractmethod
Return whether the image appears to exist only locally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
repo digest heuristic; |
Source code in src/zenml/container_engines/base.py
153 154 155 156 157 158 159 160 161 162 163 | |
login(username: str, password: str, registry: str) -> None
abstractmethod
Authenticate the container engine with the container registry credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry host or URI. |
required |
Source code in src/zenml/container_engines/base.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
login_registry(container_registry: BaseContainerRegistry) -> None
Authenticate the container engine with the container registry credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_registry
|
BaseContainerRegistry
|
Container registry to authenticate with. |
required |
Source code in src/zenml/container_engines/base.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
parse_dockerignore(dockerignore_path: str) -> List[str]
staticmethod
Parses a dockerignore file and returns a list of patterns to ignore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dockerignore_path
|
str
|
Path to the dockerignore file. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List of patterns to ignore. |
Source code in src/zenml/container_engines/base.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
push_image(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> str
abstractmethod
Push a local image to the configured registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Full image reference including tag. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Container registry to push to. Used for validation and credentials, if provided. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Repository digest when the engine reports one; otherwise an |
str
|
implementation-defined stable surrogate (e.g. unique tag). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If authentication or push fails. |
Source code in src/zenml/container_engines/base.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
sanitize_tag(tag: str) -> str
staticmethod
Sanitize a Docker tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
The tag to sanitize. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the tag is empty. |
Returns:
| Type | Description |
|---|---|
str
|
The sanitized tag. |
Source code in src/zenml/container_engines/base.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
tag_image(source: str, target: str) -> None
abstractmethod
Apply an additional local name/tag to an existing local image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Existing local image reference. |
required |
target
|
str
|
New local reference (alias) for the same image. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the engine cannot apply the tag. |
Source code in src/zenml/container_engines/base.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
DockerContainerEngine()
Bases: ContainerEngine
Container engine using the Docker CLI and/or docker-py.
Create a Docker engine (registry auth is per-operation).
Source code in src/zenml/container_engines/docker_engine.py
54 55 56 | |
Attributes
client: DockerClient
property
Return a docker-py client, reusing a cached unauthenticated instance.
Returns:
| Name | Type | Description |
|---|---|---|
DockerClient |
DockerClient
|
Connection to the local Docker daemon. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If docker-py cannot create a client from the environment (for example when the daemon is not running). |
engine_type: ContainerEngineType
property
The type of the container engine.
Returns:
| Type | Description |
|---|---|
ContainerEngineType
|
The type of the container engine. |
Functions
build(image_name: str, build_context: BuildContext, docker_build_options: Optional[DockerBuildOptions] = None, container_registry: Optional[BaseContainerRegistry] = None, **kwargs: Any) -> None
Build an image using docker-py or docker build -.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Target image reference including tag. |
required |
build_context
|
BuildContext
|
Tarball context written to the Docker daemon. |
required |
docker_build_options
|
Optional[DockerBuildOptions]
|
Optional Docker build options. |
None
|
container_registry
|
Optional[BaseContainerRegistry]
|
When set, applies registry credentials for pulls. |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/zenml/container_engines/docker_engine.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
check_availability() -> Tuple[bool, str | None]
Check whether this engine is installed and accessible and return the error message if not.
Returns:
| Type | Description |
|---|---|
bool
|
|
str | None
|
|
Source code in src/zenml/container_engines/docker_engine.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
close() -> None
Close the cached docker-py client if one was opened.
Source code in src/zenml/container_engines/docker_engine.py
448 449 450 451 452 | |
get_image_repo_digest(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> Optional[str]
Resolve a repository digest using docker-py (and registry creds).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference to resolve. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
When the name matches this registry, its credentials authenticate registry API access. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Digest string when resolvable; |
Source code in src/zenml/container_engines/docker_engine.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
is_image_local(image_name: str) -> bool
Return whether Docker considers the image local-only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/zenml/container_engines/docker_engine.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
login(username: str, password: str, registry: str) -> None
Authenticate the Docker client with the container registry credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry host or URI. |
required |
Source code in src/zenml/container_engines/docker_engine.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
login_cli(username: str, password: str, registry: str) -> None
staticmethod
Run docker login for the given registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry host or URI. |
required |
Raises:
| Type | Description |
|---|---|
AuthorizationException
|
If |
Source code in src/zenml/container_engines/docker_engine.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
login_client(username: str, password: str, registry: str) -> None
Login to a Docker registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry URI for login. |
required |
Raises:
| Type | Description |
|---|---|
AuthorizationException
|
If registry login fails. |
Source code in src/zenml/container_engines/docker_engine.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
process_docker_stream(stream: Iterable[bytes]) -> List[Dict[str, Any]]
staticmethod
Decode JSON lines from a docker-py build/push stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
Iterable[bytes]
|
Raw byte chunks from |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the stream contains an |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
Auxiliary |
Source code in src/zenml/container_engines/docker_engine.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
push_image(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> str
Push an image and return a digest or image reference string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Local image to push (must match registry URI). |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Container registry to push to. Used for validation and credentials, if provided. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Repository digest from docker-py when available; otherwise a |
str
|
string identity for the pushed image. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If push fails or the image digest is not found. |
Source code in src/zenml/container_engines/docker_engine.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | |
tag_image(source: str, target: str) -> None
Apply a local tag using the Docker engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Existing image reference. |
required |
target
|
str
|
Additional name:tag for the same image. |
required |
Source code in src/zenml/container_engines/docker_engine.py
333 334 335 336 337 338 339 340 341 | |
PodmanContainerEngine
Bases: ContainerEngine
Container engine using the Podman CLI.
Attributes
engine_type: ContainerEngineType
property
The type of the container engine.
Returns:
| Type | Description |
|---|---|
ContainerEngineType
|
The type of the container engine. |
Functions
build(image_name: str, build_context: BuildContext, docker_build_options: Optional[DockerBuildOptions] = None, container_registry: Optional[BaseContainerRegistry] = None, **kwargs: Any) -> None
Build an image using podman build with a tar context on stdin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
|
required |
build_context
|
BuildContext
|
Tarball written to build stdin. |
required |
docker_build_options
|
Optional[DockerBuildOptions]
|
Optional flags (Docker CLI compatible). |
None
|
container_registry
|
Optional[BaseContainerRegistry]
|
When set, runs |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Source code in src/zenml/container_engines/podman_engine.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
check_availability() -> Tuple[bool, str | None]
Check whether this engine is installed and accessible and return the error message if not.
Returns:
| Type | Description |
|---|---|
bool
|
|
str | None
|
|
Source code in src/zenml/container_engines/podman_engine.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_image_repo_digest(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> Optional[str]
Always return None; Podman cannot reliably report repo digests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Unused; accepted for API symmetry. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Unused; accepted for API symmetry. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
|
Optional[str]
|
engine (https://github.com/containers/podman/issues/14779). |
Source code in src/zenml/container_engines/podman_engine.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
is_image_local(image_name: str) -> bool
Return whether Podman considers the image local-only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/zenml/container_engines/podman_engine.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
login(username: str, password: str, registry: str) -> None
Run podman login for the given registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry host or URI. |
required |
Raises:
| Type | Description |
|---|---|
AuthorizationException
|
If |
Source code in src/zenml/container_engines/podman_engine.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
push_image(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> str
Push an image and return a surrogate reference when digest is absent.
Podman may not report a correct remote manifest digest; this method pushes a uniquely tagged image and returns that reference as a stable surrogate (see https://github.com/containers/podman/issues/14779).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Local image to push. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Container registry to push to. Used for validation and credentials, if provided. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A unique image reference string used as the push identity. |
Source code in src/zenml/container_engines/podman_engine.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
tag_image(source: str, target: str) -> None
Apply a local tag using Podman.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Existing image reference. |
required |
target
|
str
|
Additional name:tag for the same image. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Source code in src/zenml/container_engines/podman_engine.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
Functions
check_container_engine(engine_type: ContainerEngineType) -> Tuple[bool, str | None]
Check whether the container engine is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine_type
|
ContainerEngineType
|
Docker or Podman engine to probe. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Availability flag and, when unavailable, an error message from the |
str | None
|
engine implementation (otherwise |
Source code in src/zenml/container_engines/factory.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
get_container_engine(engine_type: Optional[ContainerEngineType] = None) -> ContainerEngine
Return the configured container engine, or auto-detect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine_type
|
Optional[ContainerEngineType]
|
When set, use this engine instead of global configuration or auto-detection. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ContainerEngine |
ContainerEngine
|
Ready-to-use engine instance. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the requested engine is unavailable or neither engine works in auto mode. |
Source code in src/zenml/container_engines/factory.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
Modules
base
Abstract container engine for local OCI-compatible tooling.
Classes
ContainerEngine
Bases: ABC
Client-side abstraction over Docker/Podman (build, tag, push, inspect).
Implementations encapsulate OCI client details; callers use the factory
functions in :mod:zenml.container_engines.factory for the active engine.
engine_type: ContainerEngineType
abstractmethod
property
The type of the container engine.
Returns:
| Type | Description |
|---|---|
ContainerEngineType
|
The type of the container engine. |
build(image_name: str, build_context: BuildContext, docker_build_options: Optional[DockerBuildOptions] = None, container_registry: Optional[BaseContainerRegistry] = None, **kwargs: Any) -> None
abstractmethod
Build an image locally from a tarball build context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Target image reference including tag. |
required |
build_context
|
BuildContext
|
Archive and Dockerfile content for the build. |
required |
docker_build_options
|
Optional[DockerBuildOptions]
|
Optional Docker-compatible build options. |
None
|
container_registry
|
Optional[BaseContainerRegistry]
|
When set, registry credentials are applied for authenticated base-image pulls during the build. |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the build fails (implementation-specific). |
Source code in src/zenml/container_engines/base.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
check_availability() -> Tuple[bool, str | None]
abstractmethod
Check whether this engine is installed and accessible and return the error message if not.
Returns:
| Type | Description |
|---|---|
bool
|
|
str | None
|
|
Source code in src/zenml/container_engines/base.py
50 51 52 53 54 55 56 57 | |
get_image_repo_digest(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> Optional[str]
abstractmethod
Resolve the repository digest for an image when the client can.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference (may include tag). |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
When set and the name matches the registry, credentials from this component are used for registry access. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Repo digest string (e.g. |
Optional[str]
|
|
Source code in src/zenml/container_engines/base.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
is_image_local(image_name: str) -> bool
abstractmethod
Return whether the image appears to exist only locally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
repo digest heuristic; |
Source code in src/zenml/container_engines/base.py
153 154 155 156 157 158 159 160 161 162 163 | |
login(username: str, password: str, registry: str) -> None
abstractmethod
Authenticate the container engine with the container registry credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry host or URI. |
required |
Source code in src/zenml/container_engines/base.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
login_registry(container_registry: BaseContainerRegistry) -> None
Authenticate the container engine with the container registry credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container_registry
|
BaseContainerRegistry
|
Container registry to authenticate with. |
required |
Source code in src/zenml/container_engines/base.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
parse_dockerignore(dockerignore_path: str) -> List[str]
staticmethod
Parses a dockerignore file and returns a list of patterns to ignore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dockerignore_path
|
str
|
Path to the dockerignore file. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List of patterns to ignore. |
Source code in src/zenml/container_engines/base.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
push_image(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> str
abstractmethod
Push a local image to the configured registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Full image reference including tag. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Container registry to push to. Used for validation and credentials, if provided. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Repository digest when the engine reports one; otherwise an |
str
|
implementation-defined stable surrogate (e.g. unique tag). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If authentication or push fails. |
Source code in src/zenml/container_engines/base.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
sanitize_tag(tag: str) -> str
staticmethod
Sanitize a Docker tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
The tag to sanitize. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the tag is empty. |
Returns:
| Type | Description |
|---|---|
str
|
The sanitized tag. |
Source code in src/zenml/container_engines/base.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
tag_image(source: str, target: str) -> None
abstractmethod
Apply an additional local name/tag to an existing local image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Existing local image reference. |
required |
target
|
str
|
New local reference (alias) for the same image. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the engine cannot apply the tag. |
Source code in src/zenml/container_engines/base.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
Functions
Modules
docker_engine
Docker-backed :class:ContainerEngine implementation.
Classes
DockerContainerEngine()
Bases: ContainerEngine
Container engine using the Docker CLI and/or docker-py.
Create a Docker engine (registry auth is per-operation).
Source code in src/zenml/container_engines/docker_engine.py
54 55 56 | |
client: DockerClient
property
Return a docker-py client, reusing a cached unauthenticated instance.
Returns:
| Name | Type | Description |
|---|---|---|
DockerClient |
DockerClient
|
Connection to the local Docker daemon. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If docker-py cannot create a client from the environment (for example when the daemon is not running). |
engine_type: ContainerEngineType
property
The type of the container engine.
Returns:
| Type | Description |
|---|---|
ContainerEngineType
|
The type of the container engine. |
build(image_name: str, build_context: BuildContext, docker_build_options: Optional[DockerBuildOptions] = None, container_registry: Optional[BaseContainerRegistry] = None, **kwargs: Any) -> None
Build an image using docker-py or docker build -.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Target image reference including tag. |
required |
build_context
|
BuildContext
|
Tarball context written to the Docker daemon. |
required |
docker_build_options
|
Optional[DockerBuildOptions]
|
Optional Docker build options. |
None
|
container_registry
|
Optional[BaseContainerRegistry]
|
When set, applies registry credentials for pulls. |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/zenml/container_engines/docker_engine.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
check_availability() -> Tuple[bool, str | None]
Check whether this engine is installed and accessible and return the error message if not.
Returns:
| Type | Description |
|---|---|
bool
|
|
str | None
|
|
Source code in src/zenml/container_engines/docker_engine.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
close() -> None
Close the cached docker-py client if one was opened.
Source code in src/zenml/container_engines/docker_engine.py
448 449 450 451 452 | |
get_image_repo_digest(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> Optional[str]
Resolve a repository digest using docker-py (and registry creds).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference to resolve. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
When the name matches this registry, its credentials authenticate registry API access. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Digest string when resolvable; |
Source code in src/zenml/container_engines/docker_engine.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
is_image_local(image_name: str) -> bool
Return whether Docker considers the image local-only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/zenml/container_engines/docker_engine.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
login(username: str, password: str, registry: str) -> None
Authenticate the Docker client with the container registry credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry host or URI. |
required |
Source code in src/zenml/container_engines/docker_engine.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
login_cli(username: str, password: str, registry: str) -> None
staticmethod
Run docker login for the given registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry host or URI. |
required |
Raises:
| Type | Description |
|---|---|
AuthorizationException
|
If |
Source code in src/zenml/container_engines/docker_engine.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
login_client(username: str, password: str, registry: str) -> None
Login to a Docker registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry URI for login. |
required |
Raises:
| Type | Description |
|---|---|
AuthorizationException
|
If registry login fails. |
Source code in src/zenml/container_engines/docker_engine.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
process_docker_stream(stream: Iterable[bytes]) -> List[Dict[str, Any]]
staticmethod
Decode JSON lines from a docker-py build/push stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
Iterable[bytes]
|
Raw byte chunks from |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the stream contains an |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
Auxiliary |
Source code in src/zenml/container_engines/docker_engine.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
push_image(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> str
Push an image and return a digest or image reference string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Local image to push (must match registry URI). |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Container registry to push to. Used for validation and credentials, if provided. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Repository digest from docker-py when available; otherwise a |
str
|
string identity for the pushed image. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If push fails or the image digest is not found. |
Source code in src/zenml/container_engines/docker_engine.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | |
tag_image(source: str, target: str) -> None
Apply a local tag using the Docker engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Existing image reference. |
required |
target
|
str
|
Additional name:tag for the same image. |
required |
Source code in src/zenml/container_engines/docker_engine.py
333 334 335 336 337 338 339 340 341 | |
Functions
factory
Resolve the active :class:ContainerEngine from global settings.
Classes
Functions
check_container_engine(engine_type: ContainerEngineType) -> Tuple[bool, str | None]
Check whether the container engine is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine_type
|
ContainerEngineType
|
Docker or Podman engine to probe. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Availability flag and, when unavailable, an error message from the |
str | None
|
engine implementation (otherwise |
Source code in src/zenml/container_engines/factory.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
get_container_engine(engine_type: Optional[ContainerEngineType] = None) -> ContainerEngine
Return the configured container engine, or auto-detect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine_type
|
Optional[ContainerEngineType]
|
When set, use this engine instead of global configuration or auto-detection. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ContainerEngine |
ContainerEngine
|
Ready-to-use engine instance. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the requested engine is unavailable or neither engine works in auto mode. |
Source code in src/zenml/container_engines/factory.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
podman_engine
Podman-backed :class:ContainerEngine implementation.
Classes
PodmanContainerEngine
Bases: ContainerEngine
Container engine using the Podman CLI.
engine_type: ContainerEngineType
property
The type of the container engine.
Returns:
| Type | Description |
|---|---|
ContainerEngineType
|
The type of the container engine. |
build(image_name: str, build_context: BuildContext, docker_build_options: Optional[DockerBuildOptions] = None, container_registry: Optional[BaseContainerRegistry] = None, **kwargs: Any) -> None
Build an image using podman build with a tar context on stdin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
|
required |
build_context
|
BuildContext
|
Tarball written to build stdin. |
required |
docker_build_options
|
Optional[DockerBuildOptions]
|
Optional flags (Docker CLI compatible). |
None
|
container_registry
|
Optional[BaseContainerRegistry]
|
When set, runs |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Source code in src/zenml/container_engines/podman_engine.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
check_availability() -> Tuple[bool, str | None]
Check whether this engine is installed and accessible and return the error message if not.
Returns:
| Type | Description |
|---|---|
bool
|
|
str | None
|
|
Source code in src/zenml/container_engines/podman_engine.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_image_repo_digest(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> Optional[str]
Always return None; Podman cannot reliably report repo digests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Unused; accepted for API symmetry. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Unused; accepted for API symmetry. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
|
Optional[str]
|
engine (https://github.com/containers/podman/issues/14779). |
Source code in src/zenml/container_engines/podman_engine.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
is_image_local(image_name: str) -> bool
Return whether Podman considers the image local-only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Image reference to inspect. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/zenml/container_engines/podman_engine.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
login(username: str, password: str, registry: str) -> None
Run podman login for the given registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Registry username. |
required |
password
|
str
|
Registry password or token. |
required |
registry
|
str
|
Registry host or URI. |
required |
Raises:
| Type | Description |
|---|---|
AuthorizationException
|
If |
Source code in src/zenml/container_engines/podman_engine.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
push_image(image_name: str, container_registry: Optional[BaseContainerRegistry] = None) -> str
Push an image and return a surrogate reference when digest is absent.
Podman may not report a correct remote manifest digest; this method pushes a uniquely tagged image and returns that reference as a stable surrogate (see https://github.com/containers/podman/issues/14779).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_name
|
str
|
Local image to push. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Container registry to push to. Used for validation and credentials, if provided. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A unique image reference string used as the push identity. |
Source code in src/zenml/container_engines/podman_engine.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
tag_image(source: str, target: str) -> None
Apply a local tag using Podman.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Existing image reference. |
required |
target
|
str
|
Additional name:tag for the same image. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If |
Source code in src/zenml/container_engines/podman_engine.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |