Difficulty: Advanced
How do you build a single Docker image tag that runs on both ARM64 (Apple Silicon, AWS Graviton) and AMD64 machines?
Use BuildKit through docker buildx build --platform linux/amd64,linux/arm64 -t org/app:1.0 --push .. Buildx builds one image per platform and pushes them under a single tag as a manifest list (an OCI image index), so docker pull on a Mac M-series laptop gets the arm64 variant and a CI runner on Intel gets the amd64 variant automatically.
A normal image manifest points to one config and one set of layers for one OS/architecture. A multi-platform image adds an index on top: a small JSON document listing several manifests, each tagged with platform: {os, architecture, variant}. When the client pulls org/app:1.0, the registry returns the index, the client picks the entry matching its own platform, and only downloads those layers. You can see this with docker buildx imagetools inspect org/app:1.0.
Running the command on a fresh machine often fails with "Multi-platform build is not supported for the docker driver". The fix depends on your setup:
--load multi-platform images locally.docker-container driver with docker buildx create --name multi --driver docker-container --use. This builder cannot load a multi-arch image into the local docker images list, so you --push to a registry instead.docker run --privileged --rm tonistiigi/binfmt --install all) or use docker/setup-qemu-action in GitHub Actions.| Strategy | How it works | Trade-off |
|---|---|---|
| QEMU emulation | Runs arm64 instructions on an amd64 CPU in user-mode emulation | Zero Dockerfile changes, but compile-heavy steps can be many times slower |
| Cross-compilation | Build stage runs on $BUILDPLATFORM and emits a binary for $TARGETARCH | Fast, needs a toolchain that cross-compiles (Go, Rust, Zig, .NET) |
| Native nodes | Append an arm64 machine to the builder with docker buildx create --append | Fastest and most faithful, costs an extra machine |
For Go services, cross-compilation is the usual answer: FROM --platform=$BUILDPLATFORM golang:1.23 AS build followed by GOOS=$TARGETOS GOARCH=$TARGETARCH go build. BuildKit fills in BUILDPLATFORM, TARGETPLATFORM, TARGETOS and TARGETARCH automatically, but you must declare them with ARG in the stage that uses them.
node:20-alpine has an arm64 variant but your custom base does not, the arm64 build fails at FROM.node_modules from your laptop into the image.$TARGETARCH in the URL, otherwise you ship an amd64 kubectl inside the arm64 image and get "exec format error" at runtime.docker run --platform linux/arm64 org/app:1.0 runs the arm64 variant under emulation so you can smoke test it before deploying to Graviton nodes.Teams moving EKS or ECS workloads to Graviton for lower cost usually adopt exactly this pipeline: one tag, two platforms, and Kubernetes schedules pods on mixed node pools without anyone choosing an architecture by hand.
# One-time: register QEMU handlers (needed on Linux hosts for emulation)
docker run --privileged --rm tonistiigi/binfmt --install all
# One-time: create a BuildKit builder that supports multi-platform output
docker buildx create --name multi --driver docker-container --use
docker buildx inspect --bootstrap # lists the platforms this builder supports
# Build both architectures and push them under one tag
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t registry.example.com/payments-api:1.4.0 \
--push .
# Confirm the tag is a manifest list with two entries
docker buildx imagetools inspect registry.example.com/payments-api:1.4.0
The docker-container driver runs BuildKit in its own container, which is what allows several platforms in one build. The imagetools output proves the tag is an index rather than a single-architecture image.
# Dockerfile
FROM --platform=$BUILDPLATFORM golang:1.23 AS build
ARG TARGETOS
ARG TARGETARCH
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Compiler runs natively on the build machine, output targets TARGETARCH
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/server ./cmd/server
FROM gcr.io/distroless/static-debian12
COPY --from=build /out/server /server
ENTRYPOINT ["/server"]
The build stage always runs on the host's native platform, so there is no QEMU slowdown. Only the final, tiny stage is per-platform, and it just copies the already compiled binary.
docker buildx, BuildKit, Manifest list, QEMU emulation, TARGETARCH, Cross-compilation