Founding prices until 15 December: 30% off Pro, locked for life. See pricing

$ … exec format error

Docker 'exec format error': wrong CPU architecture

The binary in the image was built for another CPU architecture (arm64 vs amd64), or a script lacks a shebang.

Docker

What it means

The kernel can't run the file: it's an x86-64 binary on an ARM machine (or the reverse), or a script without a #! line. It's common since Apple silicon and Graviton servers.

Causes and fixes

Most likely first. Run the check, and if it matches, apply the fix.

1. The image (or a binary downloaded in it) is for a different architecture

Check:

docker image inspect <image> --format '{{.Architecture}}'
uname -m

Fix: Build for the target with docker buildx build --platform linux/amd64,linux/arm64, and download binaries per TARGETARCH.

2. An entrypoint script without a shebang, or with CRLF line endings

Check:

head -1 entrypoint.sh | od -c | head -2

Fix: Start it with #!/bin/sh and save it with LF endings.

Fix it yourself

A live machine in your browser with this problem already on it. The grader checks the result.

Open the lab

No account needed for your first tries.

Related errors