Skip to content

docker

DockerBuilder

DockerBuilder(package, options=DefaultBuildOptions)

Enables building Chassis images locally using Docker.

To use this builder, you need to have Docker installed and have access to the Docker socket. If your Docker socket is in a non-standard location, use the appropriate Docker environment variables to tell the Docker SDK how to connect. Any environment variable supported by the official Docker Python SDK is supported.

Parameters:

Name Type Description Default
package Buildable

Chassis model object that serves as the primary model code to be containerized.

required
options BuildOptions

Object that provides specific build configuration options. See chassis.builder.options.BuildOptions for more details.

DefaultBuildOptions

build_image

build_image(name, tag='latest', cache=False, show_logs=False, clean_context=True)

Builds a local container image using the host machine Docker daemon.

To enable faster builds if you're iterating, you can set cache=True to not remove intermediate containers when the build completes. This uses more disk space but can significantly speed up subsequent builds.

To see the full log output during the Docker build, set show_logs=True.

Note

The logs will be printed at the end and will not stream as it's executing.

This method will automatically remove the build context (e.g. the temporary folder that all the files were staged in) at the end of the build. If you need to troubleshoot the files that are available to the Dockerfile, set clean_context=False and the directory will not be removed at the end of the build, allowing you to inspect it. If you want to inspect the context contents before building, see chassisml.ChassisModel.prepare_context.

Parameters:

Name Type Description Default
name str

Name of container image repository

required
tag str

Tag of container image.

'latest'
cache bool

If True caches container image layers.

False
show_logs bool

If True shows logs of the completed job.

False
clean_context bool

If False does not remove build context folder.

True

Returns:

Type Description
BuildResponse

A BuildResponse object with details from the build job.

Raises:

Type Description
BuildError

If build job fails

Example:

from chassisml import ChassisModel
from chassis.builder import DockerBuilder

model = ChassisModel(process_fn=predict)
builder = DockerBuilder(model)
res = builder.build_image(name="chassis-model")