How to Configure a Buildx Builder Instance in CI
setup-buildx-action provisions a docker-container BuildKit instance, which unlocks cache exports and multi-platform builds.
The default Docker driver cannot export cache or build multiple platforms. docker/setup-buildx-action creates a docker-container builder that can, and accepts driver-opts and a buildkitd-config for tuning.
Steps
- Add
docker/setup-buildx-actionto create adocker-containerbuilder. - Pass
driver-opts(e.g. an image or network) as needed. - Supply
buildkitd-config-inlinefor registry mirrors or limits.
Workflow
.github/workflows/docker.yml
- uses: docker/setup-buildx-action@v3
with:
driver: docker-container
driver-opts: |
network=host
buildkitd-config-inline: |
[worker.oci]
max-parallelism = 4Gotchas
- Cache export (
cache-to) and multi-platform builds require thedocker-containerdriver, not the defaultdockerdriver. - Images built with the container driver are not in the local daemon unless you add
load: true.
Related guides
How to Cache Docker Layers With a Registry Cache in CIPersist Docker build layers across CI runs with Buildx registry cache (type=registry), pushing and pulling ca…
How to Set Up a Registry Mirror for BuildKit in CIPoint the Buildx builder at a Docker Hub registry mirror in CI via a BuildKit config, cutting pull rate-limit…