Docker "exec format error" from wrong architecture in CI
The kernel tried to run a binary built for a different CPU architecture. An arm64 image on an amd64 runner (or vice versa) without emulation produces this exact error.
What this error means
A RUN step or container start fails with exec format error or exec /bin/sh: exec format error. It only happens on a host whose architecture differs from the image.
docker
exec /bin/sh: exec format error
ERROR: process "/bin/sh -c ./build.sh" did not complete successfully: exec format errorCommon causes
Image architecture differs from the host
An arm64 base or arm64-built binary is run on an amd64 runner without emulation, or vice versa.
No QEMU registered for cross-build
A multi-arch buildx build runs foreign-arch steps but QEMU binfmt was never set up.
Wrong --platform pin
A platform was forced that the host cannot execute natively.
How to fix it
Set up emulation and buildx
- Register QEMU binfmt so foreign-arch steps can run.
- Use a buildx builder for multi-platform builds.
.github/workflows/build.yml
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3Build for the host architecture
- Pin --platform to the runner architecture when you do not need cross-arch.
- Or build a true multi-platform image with buildx.
Terminal
docker build --platform linux/amd64 -t app .How to prevent it
- Match the build platform to the runner, and set up QEMU + buildx whenever you build or run images for a different architecture.
Related guides
Docker "standard_init_linux.go: exec format error" in CIFix the Docker "standard_init_linux.go: exec format error" in CI, caused by an architecture mismatch or an en…
Docker buildx "no builder instance" in CIFix the Docker buildx "ERROR: no builder ... found" / "no builder instance" error in CI when a buildx command…
Docker "OCI runtime create failed" in CIFix the Docker "OCI runtime create failed: starting container process caused" error in CI, usually a missing…