Sub topic 15
Troubleshooting common failures
This chapter assumes you can build and push images with Buildx, that you have set up a builder (see "Builders and drivers"), and that you know the three build approaches: emulation, native nodes, and cross-compilation. It covers the failures you are most likely to meet and how to tell them apart.
Start with what you can observe
Most failures fall into a few groups. Check the builder, the emulation layer, and the image itself, in that order.
Driver does not support multiple platforms
The error multiple platforms feature is currently not supported for docker driver means the active builder uses the default docker driver. Create a docker-container builder and select it:
docker buildx create --name multi --driver docker-container --use
docker buildx lsThe active builder is marked with an asterisk in the docker buildx ls output.
exec format error
This error means the kernel tried to run a binary built for another architecture. There are two common causes.
- Missing emulation. The QEMU handlers are not registered. Registration lives in the kernel, so it is lost on reboot. Reinstall the handlers and check them:
docker run --privileged --rm tonistiigi/binfmt --install all
ls /proc/sys/fs/binfmt_misc/ | grep qemu
docker run --rm --platform linux/arm64 alpine uname -mThe last command should print aarch64. If it prints x86_64, or fails, the handler is missing.
- Wrong binary in the image. A cross-compile build ran
go buildwithoutGOARCH=$TARGETARCH, or theARG TARGETARCHline is missing. AnARGdeclared beforeFROMor in another stage is not visible in the stage that uses it. The build succeeds, but the arm64 image holds an amd64 binary. Confirm withdocker run --rm --platform linux/arm64 IMAGE uname -mandfileon the binary.
Slow builds and crashes under emulation
QEMU translates every instruction, so compiling or installing packages can be 5 to 20 times slower than native. Some tools also crash with segmentation faults, especially JIT runtimes and large compilers. Retrying rarely helps. Move the heavy step off emulation by cross-compiling in a $BUILDPLATFORM stage, or add native nodes to the builder.
Load and push errors
--loadcannot store a manifest list in the classic image store, so--platform linux/amd64,linux/arm64 --loadfails. Use--push, or build one platform at a time with--load.unauthorizedordeniedon push means the builder cannot see your credentials. Rundocker loginon the machine that runs the build, and in CI use a login step before the build.- A base image with no variant for a requested platform gives
no match for platform in manifest. Check the base withdocker buildx imagetools inspect BASE_IMAGEand pick one that lists every platform you target.
Node problems in a multi-node builder
If a native node is unreachable, docker buildx inspect --bootstrap fails or marks that node as not running. Check SSH access and that Docker runs on the remote host. Also check that each node's --platform value matches the machine's real architecture. A mislabeled node produces the same wrong-architecture images as above.
Quick reference
| Symptom | Likely cause | Fix |
|---|---|---|
| Multiple platforms not supported | `docker` driver | Create a `docker-container` builder |
| exec format error at build or run | Handler missing after reboot | Reinstall with `tonistiigi/binfmt` |
| Wrong architecture inside image | `TARGETARCH` not passed | Declare `ARG` in the stage, set `GOARCH` |
| Build very slow or segfaults | Emulation overhead | Native nodes or cross-compilation |
| `--load` fails | Manifest list unsupported | Use `--push` |
Exercise
A teammate's arm64 image built on an amd64 laptop starts with "exec format error". The Dockerfile has a FROM --platform=$BUILDPLATFORM golang stage that runs go build -o /out/app .. What is the most likely cause, and how do you confirm it?
Show answer
The go build command does not set GOOS=$TARGETOS GOARCH=$TARGETARCH (and the matching ARG TARGETOS and ARG TARGETARCH lines), so Go compiled for the build platform, amd64. The arm64 image then holds an amd64 binary. Confirm by running docker run --rm --platform linux/arm64 IMAGE uname -m and checking the binary's architecture with file /usr/local/bin/app. Fix it by adding the ARG lines and the environment variables to the build step.