Interview Prep/Docker/Multi-stage builds, cache, tags and registries

Developers complain builds are slow on Apple Silicon for amd64 targets.

AdvancedScenarioMulti-stage builds, cache, tags and registries
Answer

Situation read → QEMU emulation of amd64 is 5–20x slower.

What I'd do →

  1. Cross-compile natively: FROM --platform=$BUILDPLATFORM golang AS build and set GOOS=$TARGETOS GOARCH=$TARGETARCH.
  2. Use remote native builders: docker buildx create --name farm --node amd64 --platform linux/amd64 ssh://builder plus a local arm64 node.
  3. Enable Rosetta in Docker Desktop for amd64 emulation where needed.
  4. Build multi-arch in CI on native runners and merge manifests.

Why → Native or cross-compile beats emulation.

Interview tip → Languages without easy cross-compilers need native nodes.

All Docker questions Roadmap: Docker & containers

More on Multi-stage builds, cache, tags and registries