Builder Instances

Buildx and the Builder Instance Model

A builder instance is a named BuildKit 10,294 daemon plus the driver that runs it. The default builder uses the docker driver, BuildKit built into the Engine, and writes straight into the local image store. The docker-container driver starts BuildKit in its own container, with its own cache, configuration and version; kubernetes runs it as pods, and remote connects to an existing BuildKit daemon. On a shared machine, a private builder can be pruned without touching anyone else's cache. Its buildkitd.toml allows the plain-HTTP lab registry used below and caps the cache:

buildkitd.toml: settings for a private builderShell
# BuildKit settings for a private builder instance.
# The lab registry on this machine speaks plain HTTP.
[registry."localhost:33500"]
  http = true
# Garbage collection: keep at most 4 GB of build cache, and anything used in the last 3 days.
[worker.oci]
  gc = true
  [[worker.oci.gcpolicy]]
    keepDuration = "72h"
    maxUsedSpace = "4GB"
Creating a docker-container builder next to the default oneShell
docker buildx create --name l3-builder --driver docker-container --driver-opt network=host \
  --buildkitd-config ../buildkitd.toml --bootstrap >/dev/null 2>&1
docker buildx ls | cut -c1-90
Output
NAME/NODE         DRIVER/ENDPOINT                   STATUS    BUILDKIT   PLATFORMS
l3-builder        docker-container
 \_ l3-builder0    \_ unix:///var/run/docker.sock   running   v0.32.2    linux/amd64 (+3),
default*          docker
 \_ default        \_ default                       running   v0.33.0    linux/amd64 (+3)

The asterisk marks the builder docker build uses; --builder l3-builder picks the other for one command, and docker buildx use changes the default. The Engine embeds BuildKit 0.33.0, while the container runs the moby/buildkit:buildx-stable-1 image, 0.32.2 today. network=host lets the builder reach the host's localhost:33500.