Search documentation

Type to search the documentation.

Generated API reference

classyak.Image

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.

Python SDK reference · Yak 0.1.19release v0.1.19
provenancec2e8cf7c309abe376f390072b94a9ecd3e633080
Signature
python
Image(base_image: str, instructions: Optional[List[Dict[str, Any]]] = None, is_prebuilt: bool = False, metadata: Optional[Dict[str, Any]] = None)

Parameters#

NameTypeDefaultDescription
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)

method

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

Signature
python
python_3_11() -> Image

Returns#

Image
No description supplied.
method

Image.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

Signature
python
python_3_12() -> Image

Returns#

Image
No description supplied.
method

Image.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

Signature
python
python_3_13() -> Image

Returns#

Image
No description supplied.
method

Image.debian_slim#

Create a plain Debian slim image.

Create a plain Debian slim image.

Signature
python
debian_slim() -> Image

Returns#

Image
No description supplied.
method

Image.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.

Signature
python
from_registry(image_ref: str) -> Image

Parameters#

NameTypeDefaultDescription
image_refpositional-or-keyword str —

Image reference (e.g., "python:3.11-slim", "ubuntu:22.04")

Returns#

Image
No description supplied.
method

Image.from_dockerfile#

Create an image from a Dockerfile (Phase 2 feature).

Create an image from a Dockerfile (Phase 2 feature).

Signature
python
from_dockerfile(dockerfile_path: str, context_dir: Optional[str] = None) -> Image

Parameters#

NameTypeDefaultDescription
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#

Image

New Image instance

Raises#

  • FileNotFoundError

    If Dockerfile not found

  • ValueError

    If Dockerfile is invalid

method

Image.pip_install#

Install Python packages.

Install Python packages.

Uses the fastest available package manager (uv on the platform).

Signature
python
pip_install(*packages: str, **kwargs: Any) -> Image

Parameters#

NameTypeDefaultDescription
packagesvariadic-positional str —

Package specifications (e.g., "requests", "numpy>=1.20")

kwargsvariadic-keyword Any —

Additional options (e.g., index_url, extra_index_url)

Returns#

Image

Self for method chaining

method

Image.apt_install#

Install system packages using apt-get.

Install system packages using apt-get.

Signature
python
apt_install(*packages: str) -> Image

Parameters#

NameTypeDefaultDescription
packagesvariadic-positional str —

Package names (e.g., "git", "curl", "build-essential")

Returns#

Image

Self for method chaining

method

Image.env#

Set an environment variable.

Set an environment variable.

Signature
python
env(key: str, value: str) -> Image

Parameters#

NameTypeDefaultDescription
keypositional-or-keyword str —

Environment variable name

valuepositional-or-keyword str —

Environment variable value

Returns#

Image

Self for method chaining

method

Image.run_commands#

Execute shell commands during image build.

Execute shell commands during image build.

Signature
python
run_commands(*commands: str) -> Image

Parameters#

NameTypeDefaultDescription
commandsvariadic-positional str —

Shell commands to execute

Returns#

Image

Self for method chaining

Related guides

Images
BoundaryPreview limitations
  • 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.