prefect.utilities.dockerutils
Functions
python_version_minor 
python_version_micro 
get_prefect_image_name 
- prefect_version: An optional override for the Prefect version.
- python_version: An optional override for the Python version; must be at the minor level e.g. ‘3.9’.
- flavor: An optional alternative image flavor to build, like ‘conda’
silence_docker_warnings 
docker_client 
build_image 
- context: the root directory for the Docker build context
- dockerfile: the path to the Dockerfile, relative to the context
- tag: the tag to give this image
- pull: True to pull the base image during the build
- stream_progress_to: an optional stream (like sys.stdout, or an io.TextIO) that will collect the build output as it is reported by Docker
- The image ID
push_image 
- image_id: a Docker image ID
- registry_url: the URL of a Docker registry
- name: the name of this image
- tag: the tag to give this image (defaults to a short representation of the image’s ID)
- stream_progress_to: an optional stream (like sys.stdout, or an io.TextIO) that will collect the build output as it is reported by Docker
- A registry-qualified tag, like my-registry.example.com/my-image:abcdefg
to_run_command 
parse_image_tag 
- If a tag or digest exists, this function parses and returns the image registry and tag/digest,
separately as a tuple.
- Example 1: ‘prefecthq/prefect:latest’ -> (‘prefecthq/prefect’, ‘latest’)
- Example 2: ‘hostname.io:5050/folder/subfolder:latest’ -> (‘hostname.io:5050/folder/subfolder’, ‘latest’)
- Example 3: ‘prefecthq/prefect@sha256:abc123’ -> (‘prefecthq/prefect’, ‘sha256:abc123’)
 
- Supports parsing Docker Image strings that follow Docker Image Specification v1.1.0
- Image building tools typically enforce this standard
 
- name: Name of Docker Image
split_repository_path 
- repository_path: The Docker repository path to split.
- Tuple[Optional[str], str]: A tuple containing the namespace and repository components.
- namespace (Optional[str]): The Docker namespace, combining the registry and organization. None if not present.
- repository (Optionals[str]): The repository name.
format_outlier_version_name 
packaging.version.parse validation
- Current cases are simple, but creates stub for more complicated formatting if eventually needed.
- Example outlier versions that throw a parsing exception:
- “20.10.0-ce” (variant of community edition label)
- “20.10.0-ee” (variant of enterprise edition label)
 
- version: raw docker version value
- value that can pass packaging.version.parsevalidation
generate_default_dockerfile 
- - context: The context to use for the Dockerfile. Defaults to the current working directory.
Classes
BuildError 
Raised when a Docker build fails
ImageBuilder 
An interface for preparing Docker build contexts and building images
Methods:
add_line 
add_lines 
assert_has_file 
assert_has_line 
assert_line_absent 
assert_line_after 
assert_line_before 
build 
- pull: True to pull the base image during the build
- stream_progress_to: an optional stream (like sys.stdout, or an io.TextIO) that will collect the build output as it is reported by Docker
- The image ID