Skip to main content

Docker Buildx

Docker Buildx is a Docker CLI plugin that exposes the full BuildKit feature set, including multi-platform images, external cache backends, and docker buildx bake. It is the command to use for builds beyond the basics.

What Buildx adds

docker buildx build accepts the options of docker build plus platform targets, cache import and export, attestations, and multiple builder instances. Its best-known feature is building one image tag that works on several CPU architectures through a manifest list.

Multi-platform build

Bash
# One-time builder setup
docker buildx create --name multiarch-builder --driver docker-container --use
docker buildx inspect --bootstrap
# Build and push amd64 and arm64 under one tag
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t registry.example.com/payment-api:v3.1.0 \
--push .

Clients pulling payment-api:v3.1.0 automatically receive the matching architecture, so Graviton and Apple Silicon hosts get arm64 and standard servers get amd64.

GitHub Actions

YAML
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: registry.example.com/payment-api:v3.1.0
cache-from: type=gha
cache-to: type=gha,mode=max

Other useful commands

Bash
docker buildx ls # list builders
docker buildx bake # build several targets from docker-bake.hcl
docker buildx imagetools inspect registry.example.com/payment-api:v3.1.0
Tip

Cross-architecture builds through QEMU emulation are much slower than native builds. For frequent multi-arch builds, use native runners per architecture or a remote builder.

Frequently Asked Questions

Why is Buildx needed for multi-architecture images?

A plain docker build targets the machine's own architecture. Buildx uses BuildKit with emulation or remote builders to compile each platform and publishes a manifest list under one tag so each client pulls the right image.

Why are my arm64 builds so slow on an amd64 runner?

They run under QEMU emulation, which translates every instruction in software. Use native arm64 runners or a remote builder, or cross-compile in the Dockerfile with --platform=$BUILDPLATFORM for compiled languages.

What does the docker-container driver do?

It runs BuildKit in its own container, enabling multi-platform builds and external cache exports that the default driver cannot always provide.

Found a mistake, an outdated step or a broken link?