Generated API reference
yak.Image
Builder for defining custom container images.
Builder for defining custom container images.
Provides a fluent API for constructing container images with custom
dependencies, environment variables, and commands.
provenance
c2e8cf7c309abe376f390072b94a9ecd3e633080Image(base_image: str, instructions: Optional[List[Dict[str, Any]]] = None, is_prebuilt: bool = False, metadata: Optional[Dict[str, Any]] = None)
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
base_imagepositional-or-keyword |
str |
— |
Base image reference (e.g., "python:3.11-slim") |
instructionspositional-or-keyword |
Optional[List[Dict[str, Any]]] |
None |
List of build instructions (internal use) |
is_prebuiltpositional-or-keyword |
bool |
False |
Whether this image is a pre-built Yak base image |
metadatapositional-or-keyword |
Optional[Dict[str, Any]] |
None |
Optional metadata about the image (e.g., python_version, included_tools) |
Image.python_3_11#
Create an image with Python 3.11 (debian slim base).
Create an image with Python 3.11 (debian slim base).
This uses a pre-built Yak base image for faster builds.
Pre-installed tools: python3, pip, curl, wget, git, ca-certificates
python_3_11() -> Image
Returns#
ImageImage.python_3_12#
Create an image with Python 3.12 (debian slim base).
Create an image with Python 3.12 (debian slim base).
This uses a pre-built Yak base image for faster builds.
Pre-installed tools: python3, pip, curl, wget, git, ca-certificates
python_3_12() -> Image
Returns#
ImageImage.python_3_13#
Create an image with Python 3.13 (debian slim base).
Create an image with Python 3.13 (debian slim base).
This uses a pre-built Yak base image for faster builds.
Pre-installed tools: python3, pip, curl, wget, git, ca-certificates
python_3_13() -> Image
Returns#
ImageImage.debian_slim#
Create a plain Debian slim image.
Create a plain Debian slim image.
debian_slim() -> Image
Returns#
ImageImage.from_registry#
Build a custom image rooted at an existing registry image.
Build a custom image rooted at an existing registry image.
The registry reference is the custom builder's base. The platform
resolves its immutable manifest digest before build identity and
execution, including when this image has no fluent instructions.
Use a task-level string when the task should run directly from a
registry image without entering the custom image builder.
from_registry(image_ref: str) -> Image
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
image_refpositional-or-keyword |
str |
— |
Image reference (e.g., "python:3.11-slim", "ubuntu:22.04") |
Returns#
ImageImage.from_dockerfile#
Create an image from a Dockerfile (Phase 2 feature).
Create an image from a Dockerfile (Phase 2 feature).
from_dockerfile(dockerfile_path: str, context_dir: Optional[str] = None) -> Image
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
dockerfile_pathpositional-or-keyword |
str |
— |
Path to Dockerfile |
context_dirpositional-or-keyword |
Optional[str] |
None |
Build context directory (for COPY/ADD) - defaults to dirname(dockerfile_path) |
Returns#
ImageNew Image instance
Raises#
FileNotFoundErrorIf Dockerfile not found
ValueErrorIf Dockerfile is invalid
Image.pip_install#
Install Python packages.
Install Python packages.
Uses the fastest available package manager (uv on the platform).
pip_install(*packages: str, **kwargs: Any) -> Image
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
packagesvariadic-positional |
str |
— |
Package specifications (e.g., "requests", "numpy>=1.20") |
kwargsvariadic-keyword |
Any |
— |
Additional options (e.g., index_url, extra_index_url) |
Returns#
ImageSelf for method chaining
Image.apt_install#
Install system packages using apt-get.
Install system packages using apt-get.
apt_install(*packages: str) -> Image
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
packagesvariadic-positional |
str |
— |
Package names (e.g., "git", "curl", "build-essential") |
Returns#
ImageSelf for method chaining
Image.env#
Set an environment variable.
Set an environment variable.
env(key: str, value: str) -> Image
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
keypositional-or-keyword |
str |
— |
Environment variable name |
valuepositional-or-keyword |
str |
— |
Environment variable value |
Returns#
ImageSelf for method chaining
Image.run_commands#
Execute shell commands during image build.
Execute shell commands during image build.
run_commands(*commands: str) -> Image
Parameters#
| Name | Type | Default | Description |
|---|---|---|---|
commandsvariadic-positional |
str |
— |
Shell commands to execute |
Returns#
ImageSelf for method chaining
Related guides
- This page is generated from the pinned release schema; update the site pin when a new release should be documented.
- Lifecycle, persistence and operational context belong in the linked handwritten guides.