Home › Docker

exec format error — how to fix

exec /usr/local/bin/docker-entrypoint.sh: exec format error

Quick fix: Architecture mismatch: build for the target platform with docker buildx build --platform linux/amd64 ... (or arm64). Script: make sure the first line is a shebang like #!/bin/sh and the file uses Unix line endings.

What it means

The Linux kernel was asked to run a file it can't execute. Inside containers that almost always means one of two things.

Cause 1: wrong CPU architecture

An image built on an Apple Silicon Mac (arm64) won't run on a typical x86-64 server, and an amd64 image won't run on a Raspberry Pi.

Check the image's architecture:

docker image inspect myimage --format '{{.Os}}/{{.Architecture}}'
uname -m        # on the machine that runs it: x86_64 = amd64, aarch64 = arm64

Build for the right platform:

docker buildx build --platform linux/amd64 -t myimage:latest .
# or a multi-platform image (requires pushing to a registry):
docker buildx build --platform linux/amd64,linux/arm64 -t user/myimage:latest --push .

In Compose, add platform: linux/amd64 to the service.

Cause 2: a script without a valid shebang

If the entrypoint is a shell script, its first line must say which interpreter to use:

#!/bin/sh

Also check:

Outside Docker

The same error on a normal Linux machine means you downloaded a binary for the wrong architecture (for example an arm64 release on an x86 server). Download the build that matches uname -m.

Last updated 2026-10-27.