$ run as a normal user# run as root (or with sudo)
The quick answer
docker buildx create --name multi --use
docker buildx inspect --bootstrap
docker buildx build --platform linux/amd64,linux/arm64 -t registry.example.com/shop/api:1.4.2 --push .
docker buildx imagetools inspect registry.example.com/shop/api:1.4.2The result is a manifest list: one tag, two images (amd64 + arm64).
Step by step
- A builder that can build several platforms — the
docker-containerdriver (quick answer). On an x86 machine, building ARM uses QEMU emulation; install it once ifinspectdoes not listlinux/arm64:
docker run --privileged --rm tonistiigi/binfmt --install arm64- Build and push (quick answer). Multi-platform images must be pushed (or exported) — the local Docker image store can not hold a list by default.
- Make the Dockerfile platform-aware — base images must exist for both (official images do), and downloads must pick the right binary:
FROM --platform=$BUILDPLATFORM golang:1.24 AS build
ARG TARGETOS TARGETARCH
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/api ./cmd/api
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/api /api
ENTRYPOINT ["/api"]Cross-compiling (--platform=$BUILDPLATFORM for the build stage) is much faster than emulating the whole build.
- Check what was pushed:
docker buildx imagetools inspect registry.example.com/shop/api:1.4.2
Manifests:
Name: registry.example.com/shop/api:1.4.2@sha256:9b1c…
Platform: linux/amd64
Name: registry.example.com/shop/api:1.4.2@sha256:3e7a…
Platform: linux/arm64- Speed up with a cache in CI:
docker buildx build --platform linux/amd64,linux/arm64 --cache-from type=registry,ref=registry.example.com/shop/api:buildcache --cache-to type=registry,ref=registry.example.com/shop/api:buildcache,mode=max -t registry.example.com/shop/api:1.4.2 --push .- Test one platform locally:
docker run --rm --platform linux/arm64 registry.example.com/shop/api:1.4.2 --versionCheck that it worked
imagetools inspect lists both linux/amd64 and linux/arm64, and the same tag runs on an x86 server and an ARM node without exec format error.
Common problems
| Problem | Cause | Fix |
|---|---|---|
exec format error | Image built for the other CPU. | Build multi-platform; check with imagetools inspect. |
multiple platforms feature is currently not supported for docker driver | Default builder. | docker buildx create --use (docker-container driver). |
| ARM build is very slow | Full emulation with QEMU. | Cross-compile in the build stage, or use native ARM runners. |
no match for platform in manifest | A base image has no ARM variant. | Choose a base image that supports both. |
Image not in docker images after build | Multi-platform result was pushed, not loaded. | Use --load with one platform for local tests. |
| Downloaded binary is x86 inside the ARM image | Hard-coded download URL. | Use TARGETARCH in the URL. |
Go further
- Command pages: docker, buildah.
- Next how-tos: Write a small and safe Dockerfile, Push an image to a private registry, Create a CI pipeline in GitHub Actions.
- Learn it: Docker — Multi-stage builds, Images in DevOps. Full guide: Docker.
1What does a multi-platform image look like in the registry?
One tag pointing to a manifest list with one image per platform (for example amd64 and arm64).
2Why cross-compile in the build stage instead of emulating?
The build runs natively and only the target binary is for ARM — much faster than QEMU emulation.