Docker "exec format error" - Fix Architecture/Shebang Mismatch in CI
The kernel could not execute the binary the container tried to run. Almost always the image (or an entrypoint binary) is built for a different CPU architecture than the host -- for example an arm64 image on an amd64 runner -- or a script has no valid shebang.
What this error means
The container fails immediately with exec /entrypoint: exec format error or standard_init_linux.go: exec user process caused: exec format error. It is deterministic for a given image+host pairing -- the architectures simply do not match.
exec /usr/local/bin/app: exec format error
# or
standard_init_linux.go:228: exec user process caused: exec format errorCommon causes
Image built for a different architecture
An image built for linux/arm64 is run on a linux/amd64 host (or vice versa). Without emulation the host kernel cannot execute the foreign binary.
Binary compiled for the wrong target
A statically compiled entrypoint targeted a different arch than the runner, so it cannot be exec'd even if the base image is correct.
Script missing a valid shebang
An entrypoint shell script with no #!/bin/sh line, or a CRLF-corrupted shebang, can also produce exec format error.
How to fix it
Build/pull for the host architecture
Match the image platform to the runner, or build multi-arch with buildx.
# pull/run the right platform
docker run --platform linux/amd64 myorg/app:1.4.2
# build multi-arch
docker buildx build --platform linux/amd64,linux/arm64 -t myorg/app:1.4.2 --push .Fix a binary or script target
- Compile entrypoint binaries for the target architecture (set GOARCH/GOOS for Go).
- Ensure entrypoint scripts start with a valid shebang and use LF line endings.
- For cross-arch runs, register QEMU with docker/setup-qemu-action before running.
How to prevent it
- Build multi-arch images with buildx when targets vary.
- Pin
--platformso an image always runs on a matching host. - Keep entrypoint scripts shebang-correct and free of CRLF endings.