GrepBoard/Manuals
605 manuals ·

Fix Docker exec format error: image built for the wrong CPU

·Tested on Ubuntu 24.04 · Docker Engine 29.9.2 · busybox 1.37 · 2026-10·Test scope ↓·6 steps

Docker "exec format error" usually means an arm64 image on amd64. Check the image architecture, rebuild with --platform, or add a shebang to the entrypoint.

output
exec /bin/uname: exec format error

The binary inside the container was not built for this host's CPU. The usual case is an image built on an Apple Silicon Mac (arm64) and run on an x86_64 server, so the fix belongs where the image is built, not on the server. The same message also appears when an entrypoint script has no #! line; step 5 tells the two apart.

[1] Check the host CPU.

console
$ uname -mx86_64

x86_64 is linux/amd64 in Docker terms; aarch64 is linux/arm64.

[2] Check which platform the image is for. A single-platform image answers directly.

console
$ docker image inspect --format '{{.Os}}/{{.Architecture}}' arm64v8/busybox:1.37linux/arm64

An arm64 image on an amd64 host settles it. Run it without a platform and Docker prints a warning first, then the error:

output
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v2) and no specific platform was requestedexec /bin/uname: exec format error

Logs often cut the warning off and keep only the error. If you see that warning, go to step 3.

console
$ docker image ls --tree busybox:1.37IMAGE                   ID             DISK USAGE   CONTENT SIZE   EXTRAbusybox:1.37            bdf57e528e45       12.8MB         4.12MB├─ linux/amd64          66a6306db78b        6.7MB         2.21MB├─ linux/arm/v5         88132f86ce62           0B             0B├─ linux/arm64/v8       d82c2ab94640       6.07MB          1.9MB

(Only some rows are shown.)

[3] Rebuild the image for the server's platform. Set the platform where you build.

console
$ docker build --platform linux/amd64 -t registry.example.com/app:1.4 .

If both Macs and servers use the image, build both platforms at once. Per the docs, multi-platform images need an image store that supports manifest lists; Docker Desktop and Docker Engine 29.0 and later use the containerd store by default, which does.

console
$ docker buildx build --platform linux/amd64,linux/arm64 -t registry.example.com/app:1.4 --push .

If changing the build flag changes nothing, look for a hard-coded --platform=linux/arm64 on a FROM line in the Dockerfile. That line pulls the base image for that platform.

[4] Check the platform you pull and run. Even a multi-platform image fails on amd64 if you ask for arm64:

console
$ docker run --rm --platform linux/arm64 busybox:1.37 uname -mexec /bin/uname: exec format error$ docker run --rm --platform linux/amd64 busybox:1.37 uname -mx86_64

A platform: key in a Compose file and the DOCKER_DEFAULT_PLATFORM environment variable in CI do the same thing, so search for them too. If the registry has no build for your platform at all, you get a different error before anything runs:

output
docker: Error response from daemon: no matching manifest for linux/amd64 in the manifest list entries: no match for platform in manifest: not found

That means the publisher never pushed an amd64 build. Check the supported platforms on the image page.

[5] If the platform matches and the error remains, look at the first line of the entrypoint script. A script without a shebang such as #!/bin/sh, run directly as ENTRYPOINT, gives the kernel nothing to go on and fails the same way:

output
exec /noshebang.sh: exec format error

Add #!/bin/sh (or #!/bin/bash) as the first line and the same image runs. If the shebang is there but you get no such file or directory, the file has CRLF line endings — see /bin/bash^M: bad interpreter.

[6] If you really must run a foreign-CPU image on this host, the docs register QEMU emulation like this:

console
$ docker run --privileged --rm tonistiigi/binfmt --install all

To register only what you need, name the architecture, e.g. --install arm64. Running docker run --privileged --rm tonistiigi/binfmt with no arguments prints the emulators currently registered (emulators).

To undo: remove registered emulators with --uninstall from the same image (binfmt README):

console
$ docker run --privileged --rm tonistiigi/binfmt --uninstall qemu-aarch64$ docker run --privileged --rm tonistiigi/binfmt --uninstall 'qemu-*'

The first line removes only the arm64 emulator; the second removes all QEMU emulators. Take the names from the status output above. Docker Desktop supports emulation by default without this.

#docker#exec-format-error#platform#arm64