docker
DockerBuilder
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
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 |
Raises:
Type | Description |
---|---|
BuildError | If build job fails |
Example: