openhands.runtime.builder.docker
DockerRuntimeBuilder Objects
class DockerRuntimeBuilder(RuntimeBuilder)
build
def build(path: str,
tags: list[str],
platform: str | None = None,
use_local_cache: bool = False,
extra_build_args: list[str] | None = None) -> str
Builds a Docker image using BuildKit and handles the build logs appropriately.
Arguments:
path
str - The path to the Docker build context.tags
list[str] - A list of image tags to apply to the built image.platform
str, optional - The target platform for the build. Defaults to None.use_local_cache
bool, optional - Whether to use and update the local build cache. Defaults to True.extra_build_args
list[str], optional - Additional arguments to pass to the Docker build command. Defaults to None.
Returns:
str
- The name of the built Docker image.
Raises:
RuntimeError
- If the Docker server version is incompatible or if the build process fails.
Notes:
This method uses Docker BuildKit for improved build performance and caching capabilities.
If use_local_cache
is True, it will attempt to use and update the build cache in a local directory.
The extra_build_args
parameter allows for passing additional Docker build arguments as needed.
image_exists
def image_exists(image_name: str, pull_from_repo: bool = True) -> bool
Check if the image exists in the registry (try to pull it first) or in the local store.
Arguments:
image_name
str - The Docker image to check (<image repo>:<image tag>)pull_from_repo
bool - Whether to pull from the remote repo if the image not present locally
Returns:
bool
- Whether the Docker image exists in the registry or in the local store