Docker "exec format error" - Fix Architecture Mismatch in CI
The kernel could not execute the container’s entrypoint binary because it was compiled for a different CPU architecture. The image and the runner do not match.
What this error means
A container starts then immediately exits with exec format error (often exec /usr/bin/...: exec format error). The image runs fine on a host of the matching architecture.
exec /docker-entrypoint.sh: exec format error
# or the older runtime phrasing:
standard_init_linux.go:228: exec user process caused: exec format errorCommon causes
Image built for a different architecture
An arm64 image run on an amd64 host (or vice versa) cannot execute its binaries. Common when an image built on Apple Silicon is run on amd64 CI, or an explicit --platform mismatch.
Missing QEMU/binfmt for emulation
Running a foreign-arch image requires binfmt_misc/QEMU registered. Without it the kernel has no interpreter for the foreign binary.
A script lacks a shebang or has CRLF endings
A non-binary entrypoint script with no #! line, or Windows CRLF line endings, can also surface as exec format error.
How to fix it
Build/pull for the runner’s architecture
Make the image platform match the host, or build multi-arch.
docker pull --platform linux/amd64 myorg/api:1.4.2
# or build for the target explicitly
docker build --platform linux/amd64 -t myorg/api:1.4.2 .Register QEMU to run foreign-arch images
Set up binfmt so the host can emulate the other architecture.
docker run --privileged --rm tonistiigi/binfmt --install all
# in Actions:
- uses: docker/setup-qemu-action@v3How to prevent it
- Match build and run architectures, or publish multi-arch images.
- Register QEMU when you must run foreign-arch images in CI.
- Enforce LF endings and shebangs on entrypoint scripts.