build.build()
Build a Docker image from a Dockerfile.
Usage
build.build(
dockerfile=Path(".") / "Dockerfile",
image_name="tugboat",
tag="latest",
platforms=["linux/amd64", "linux/arm64"],
build_args=None,
build_context=str(Path(".").resolve()),
push=False,
dh_username=None,
dh_password=None,
verbose=False
)Parameters
dockerfile: str or Path = Path(".") / "Dockerfile"-
Path to the Dockerfile to build.
image_name: str = "tugboat"-
Name to assign to the built Docker image.
tag: str = "latest"-
Tag to assign to the built Docker image.
platforms: list of str or str = ["linux/amd64", "linux/arm64"]-
One or more target platforms to build the image for.
build_args: list of str or None = None-
Additional arguments to pass through to
docker buildx build. build_context: str = current working directory-
Path to the build context directory.
push: bool = False-
Whether to push the built image to DockerHub. If True, both
dh_usernameanddh_passwordmust be provided. dh_username: str or None = None-
DockerHub username. Required if
pushis True. dh_password: str or None = None-
DockerHub password. Required if
pushis True. verbose: bool = False-
Whether to print the underlying
docker buildx buildcommand before executing it.
Returns
str-
The full image reference, in the form
{repository}:{tag}.
Raises
DockerNotFoundError-
If Docker is not installed.
RuntimeError-
If
pushis True butdh_usernameordh_passwordis missing, if the Docker login fails, or if the build fails.