Local Image Builder

Building container images locally.

The local image builder is an image builder flavor that comes built-in with ZenML and uses the local Docker installation on your client machine to build container images.

ZenML uses the official Docker Python library to build and push your images. This library loads its authentication credentials to push images from the default config location: $HOME/.docker/config.json. If your Docker configuration is stored in a different directory, you can use the environment variable DOCKER_CONFIG to override this behavior:

export DOCKER_CONFIG=/path/to/config_dir

The directory that you specify here must contain your Docker configuration in a file called config.json.

When to use it

You should use the local image builder if:

  • you're able to install and use Docker on your client machine.

  • you want to use remote components that require containerization without the additional hassle of configuring infrastructure for an additional component.

How to deploy it

The local image builder comes with ZenML and works without any additional setup.

How to use it

To use the Local image builder, we need:

  • Docker installed and running.

  • The Docker client authenticated to push to the container registry that you intend to use in the same stack.

We can then register the image builder and use it to create a new stack:

Use the Docker CLI for builds (subprocess mode)

By default, the local image builder uses the Docker Python SDK to run builds. You can alternatively configure it to call the Docker CLI (docker build) via a subprocess. This can help if you require some options that are only available for Docker BuildKit, which is not supported in the Python SDK yet.

Enable subprocess mode when registering or updating the component:

In subprocess mode, the build options passed via DockerSettings are handled in the following way:

  • The buildargs, labels dictionaries are passed as --build-arg KEY=VALUE and --label KEY=VALUE respectively

  • Lists will pass multiple command line arguments with the same name for all values

  • True boolean values means the argument will be passed without any value (--KEY)

  • All other values are converted to a string and passed as --KEY VALUE

For more information and a full list of configurable attributes of the local image builder, check out the SDK Docs .

ZenML Scarf

Last updated

Was this helpful?