Back to Prefect

docker_image

docs/v3/api-ref/python/prefect-docker-docker_image.mdx

3.6.30.dev32.0 KB
Original Source

prefect.docker.docker_image

Classes

DockerImage <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/docker/docker_image.py#L32" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Configuration used to build and push a Docker image for a deployment.

Attributes:

  • name: The name of the Docker image to build, including the registry and repository.
  • tag: The tag to apply to the built image.
  • dockerfile: The path to the Dockerfile to use for building the image. If not provided, a default Dockerfile will be generated.
  • stream_progress_to: A stream to write build and push progress output to. Defaults to sys.stdout. Set to None to suppress output.
  • build_backend: The backend to use for building images. "docker-py" (default) uses the docker-py library. "buildx" uses python-on-whales for BuildKit/buildx support, enabling features like build secrets, SSH forwarding, and multi-platform builds.
  • **build_kwargs: Additional keyword arguments to pass to the Docker build request. When build_backend="docker-py", these are forwarded to docker-py's client.api.build(). When build_backend="buildx", these are forwarded to python_on_whales.docker.buildx.build() and may include secrets, ssh, cache_from, cache_to, platforms, and push.

Methods:

build <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/docker/docker_image.py#L100" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
build(self) -> None

push <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/docker/docker_image.py#L154" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
push(self) -> None

reference <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/docker/docker_image.py#L97" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
reference(self) -> str