Skip to content
Back to Cloud Services

Multi-arch Docker images with buildx for amd64 and arm64

Build and push a single multi-arch manifest that pulls the right image (amd64/arm64) on any host.

Docker HostingIntermediate

Why

Apple Silicon (arm64) and AWS Graviton (arm64, 20% cheaper) need arm64 images, while most CI and older servers are amd64. A multi-arch manifest lets one tag serve both, so `docker pull` works everywhere without per-arch tags.

Docker is used by 59% of professional developers per the Stack Overflow 2024 survey. Docker Hub has 15M+ public images, and OCI image spec adoption means containers run identically across Docker, Podman, and containerd.

When

Use when you deploy to mixed-arch fleets (Mac dev + Linux prod, or amd64 + Graviton on AWS) or publish public images for broad consumption. Avoid Docker Desktop for production (license requires paid plan for 250+ employees) — use containerd or Podman.

Skip Docker for single-binary Go/Rust apps — a static binary + systemd is simpler.

How

1. Enable buildx: `docker buildx create --use --name multiarch`. 2. Build and push in one command: `docker buildx build --platform linux/amd64,linux/arm64 -t user/app:1.0 --push .`. 3. The Dockerfile must be arch-aware: use `FROM --platform=\$BUILDPLATFORM golang:1.22 AS build` to cross-compile, then `FROM --platform=\$TARGETPLATFORM alpine` for the runtime. 4. For QEMU emulation (slow), run `docker run --privileged --rm tonistiigi/binfmt --install all` first. 5. For faster native builds, use a buildx builder with remote arm64 and amd64 nodes.

Example

# Dockerfile.multiarch — cross-compile Go, then copy to target arch alpine FROM --platform=\$BUILDPLATFORM golang:1.22 AS build ARG TARGETPLATFORM WORKDIR /src COPY . . RUN CGO_ENABLED=0 GOOS=\$(echo \${TARGETPLATFORM} | cut -d/ -f1) \ GOARCH=\$(echo \${TARGETPLATFORM} | cut -d/ -f2) \ go build -o /app . FROM --platform=\$TARGETPLATFORM alpine:3.19 COPY --from=build /app /app ENTRYPOINT ["/app"] # Build and push both arches docker buildx build --platform linux/amd64,linux/arm64 \ -t user/app:1.0 --push .

Common Problems

  • ⚠QEMU emulation is 10-50x slower than native — CI builds take 30min instead of 2min.
  • ⚠C/C++/Rust binaries built on amd64 for arm64 without cross-toolchain fail at runtime with exec format error.
  • ⚠Forgetting --push leaves the manifest local; the registry never sees it and pulls 404.

Best Practices

  • ✓Use a buildx builder with native arm64 (Graviton EC2 or Mac) and amd64 nodes for fast parallel builds.
  • ✓Cross-compile interpreted languages (Node, Python) — they're arch-agnostic, so one stage suffices.
  • ✓Test on both arches in CI before pushing; a build that succeeds on amd64 can segfault on arm64.

FAQ

What is Multi-arch Docker images with buildx for amd64 and arm64 and what problem does it solve?

Build and push a single multi-arch manifest that pulls the right image (amd64/arm64) on any host. It lets developers deploy, store, and scale without self-managing infrastructure — a core reference for cloud service selection.

How do I get started with Multi-arch Docker images with buildx for amd64 and arm64 in 5 minutes?

Two steps to run it: (1) Enable buildx: `docker buildx create --use --name multiarch`.; (2) Build and push in one command: `docker buildx build --platform linux/amd64,linux/arm64 -t user/app:1.0 --push .`.. Validate on the free tier first, then wire into production.

What is the #1 pitfall with Multi-arch Docker images with buildx for amd64 and arm64?

The most frequent issue is: QEMU emulation is 10-50x slower than native — CI builds take 30min instead of 2min.. Run a pre-launch checklist item by item, and add policy/config scanning in CI.

What are the best practices for Multi-arch Docker images with buildx for amd64 and arm64?

Best practices for Multi-arch Docker images with buildx for amd64 and arm64 include: Use a buildx builder with native arm64 (Graviton EC2 or Mac) and amd64 nodes for fast parallel builds.; Cross-compile interpreted languages (Node, Python) — they're arch-agnostic, so one stage suffices.; Test on both arches in CI before pushing; a build that succeeds on amd64 can segfault on arm64.. The first one — "Use a buildx builder with native arm64 (Graviton EC2 or Mac) and amd64 nodes for fast parallel builds." — should be a team default baked into your IaC templates.

How do I control cost and avoid bill surprises with Multi-arch Docker images with buildx for amd64 and arm64?

Three ways to prevent overspend: (1) tag every resource with env/team and enable billing alarms; (2) set budget thresholds to trigger Slack/email alerts; (3) review idle resources in Cost Explorer regularly and clean them up. Most Multi-arch Docker images with buildx for amd64 and arm64 options offer a free tier — validate within free quota before scaling.