Fix Docker "exec format error" (Architecture Mismatch)
The container starts, then dies with "exec format error." Here's why the CPU architecture is wrong, how to confirm it, and how to build images that just run.
Key takeaways
- Docker exec format error means the kernel cannot run the container's entrypoint, almost always because the image was built for another CPU, such as an arm64 image from an Apple Silicon Mac on an amd64 server.
- Compare docker image inspect against uname -m, then rebuild with docker buildx build --platform linux/amd64,linux/arm64.
On this page
Docker's "exec format error" means the kernel refused to run the container's entrypoint, and the cause is almost always an architecture mismatch: an arm64 image on an amd64 host, or the reverse. Confirm with docker image inspect --format '{{.Architecture}}' against uname -m, then rebuild multi-arch with docker buildx build --platform linux/amd64,linux/arm64.
Verified against
Docker Engine 29.9.2, Buildx v0.38.1, against the Docker multi-platform build docs, the docker buildx build reference, and the execve(2) man page (man-pages 6.19). Checked October 2026.
exec /usr/local/bin/app: exec format error
The four causes, with the one-line check for each:
- Architecture mismatch (by far the most common): image arch differs from
uname -m. - Missing shebang on a script entrypoint:
head -1 entrypoint.shshows no#!. - UTF-8 byte order mark before the
#!:file entrypoint.shreports "with BOM". - Wrong-format binary copied in from the build host:
file /usr/local/bin/appshows the wrong machine.
This got far more common once laptops moved to Apple Silicon. Your laptop is arm64, your production servers are probably amd64 (x86_64). You build locally, it runs on your machine, and the deploy box refuses to execute it.
What "exec format error" actually means
When the kernel runs a binary, it reads the file header to learn the instruction set. If the header says ARM and the CPU speaks x86, execve(2) fails with ENOEXEC, which the man page describes as an executable "not in a recognized format, is for the wrong architecture". Docker passes that message straight through. It's a kernel error; Docker is the messenger.
Diagnosis: confirm it's the architecture
Before you change anything, prove the mismatch. Three commands settle it:
docker image inspect myapp:latest --format '{{.Architecture}} / {{.Os}}'
arm64 / linux
uname -m
x86_64
docker version --format '{{.Server.Arch}}'
amd64
x86_64 needs amd64 images; aarch64 needs arm64. If the image says arm64 and the host says x86_64, that's your whole problem.
For a multi-arch image already in a registry, list every variant it ships without pulling it:
docker buildx imagetools inspect myorg/myapp:latest
If your platform is missing from the Manifests: list, the image was never built for you.
Fix 1: pull and run the right platform
If a correct build exists in the registry, ask for it explicitly:
docker pull --platform linux/amd64 myorg/myapp:latest
docker run --platform linux/amd64 myorg/myapp:latest
This is the quick unblock, but treat it as a band-aid. If you have to hand --platform to every command, the real fix is building the image properly.
Fix 2: build multi-arch with buildx (the real fix)
Publish one tag that carries both architectures, so nobody has to think about it again:
docker buildx create --name multi --driver docker-container --use --bootstrap
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t myorg/myapp:latest \
--push .
docker buildx imagetools inspect myorg/myapp:latest | grep Platform
Platform: linux/amd64
Platform: linux/arm64
That publishes a manifest list. An arm64 box pulling myapp:latest gets the arm64 layers; the amd64 server gets amd64. Same tag, correct binary, zero flags at runtime. Our multi-arch Docker builds with buildx guide covers caching and CI matrix builds.
One catch: Docker's docs say results from a docker-container builder aren't loaded into your local image store, so push multi-arch builds straight to the registry. Docker Desktop and Docker Engine 29.0+ use the containerd image store by default, which can hold multi-platform images locally, but on Engine that default applies to fresh installs; an engine upgraded in place may still use classic storage (as of October 2026).
Fix 3: QEMU emulation when you must build the other arch
If your builder is amd64 but you need arm64 layers (or vice versa), register QEMU binfmt handlers so the foreign architecture can run during the build:
docker run --privileged --rm tonistiigi/binfmt --install all
cat /proc/sys/fs/binfmt_misc/qemu-aarch64 | grep flags
flags: F
The F flag confirms registration. It's slower because the foreign side runs under emulation, but it works, and it's what most single-runner CI setups rely on. Docker Desktop already bundles QEMU, so Mac and Windows users can skip this step.
Fix 4: don't lock the base image to one arch
Sometimes the mismatch sneaks in through FROM. An arch-specific tag like arm64v8/node pins the image to one platform forever. Use the multi-arch tag (node:22) and let buildx resolve the platform, or pin a digest of the manifest list, not of one platform's image.
The variant that isn't about CPU: scripts
If your entrypoint is a shell script, the kernel reads the first two bytes looking for #!. When they aren't there, execve returns the same ENOEXEC:
- No shebang at all. A shell would guess
sh; Docker's runtime callsexecvedirectly and does not. - A UTF-8 BOM saved by a Windows editor puts three invisible bytes before
#!.
Two look-alikes produce a different error, exec /entrypoint.sh: no such file or directory, because the interpreter named in the shebang doesn't exist (ENOENT):
- Windows line endings.
#!/bin/sh\rasks for an interpreter literally namedsh\r. Rundos2unixor set*.sh text eol=lfin.gitattributes. #!/bin/bashon Alpine, which ships only/bin/shunless you install bash.
head -1 entrypoint.sh
#!/bin/sh
file entrypoint.sh
entrypoint.sh: POSIX shell script, ASCII text executable, with CRLF line terminators
The exact messages, and what each one means
exec /usr/local/bin/app: exec format error: current runc wording forENOEXEC. Architecture first, then the script checks above.standard_init_linux.go:228: exec user process caused: exec format error: the same failure from older runc versions; same fixes.The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64): a warning atdocker runthat predicts the crash. Rebuild or pass--platform.no match for platform in manifest: not found: you asked for a--platformthe image doesn't ship. Checkimagetools inspect.- Exit code 139 instead of an error: a binary that started under emulation and then segfaulted. Treat it as a reason to build natively; see why a container exits immediately for the exit-code table.
Where this breaks: none of this helps if the binary itself is fine but links against the wrong libc (a glibc binary copied into Alpine fails with no such file or directory, not a format error). And emulation is a build-time or testing crutch; production workloads should run native images.
Questions people ask
How do I fix exec format error on an Apple Silicon Mac?
Your Mac builds linux/arm64 images by default, and an amd64 server cannot execute them. Build for the server with docker buildx build --platform linux/amd64 -t myorg/myapp --push ., or for both with --platform linux/amd64,linux/arm64. Docker Desktop supports building under emulation by default, so the cross-build works on the Mac, just slower than a native build.
Can I run an amd64 image on an arm64 host anyway?
Yes, through emulation. Register QEMU handlers with docker run --privileged --rm tonistiigi/binfmt --install all, then start the container with docker run --platform linux/amd64 IMAGE. It works for testing and CI, but expect emulated workloads to run noticeably slower than native ones, so publish a native arm64 variant for anything long-running.
Why does my entrypoint script give exec format error?
Because the kernel could not find #! in the first two bytes of the file. Either the script has no shebang, or an editor saved it with a UTF-8 byte order mark in front of it. Add #!/bin/sh as line one, re-save without a BOM, and rebuild. If the error says "no such file or directory" instead, check for CRLF line endings.
The call we'd make
Stop building single-arch images by hand. The moment your team has one Apple Silicon laptop and one x86 server, single-arch is a trap that bites on a Friday deploy. Move the buildx --platform linux/amd64,linux/arm64 --push build into CI so every published tag is multi-arch by default, and drop --platform from your run commands. Runtime flags papering over a build problem are debt, and this is one of the cheapest to pay off. Other failures in the same family are mapped in our Docker troubleshooting guide.
Sources
Cite this article
Kiril Urbonas (2026). Fix Docker "exec format error" (Architecture Mismatch). DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/fix-docker-exec-format-error
[Fix Docker "exec format error" (Architecture Mismatch)](https://www.devopsness.com/blog/fix-docker-exec-format-error) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from DevOps
Explore more articles in this category
GitHub Actions Pricing and Minute Optimization
How GitHub Actions billing actually works in 2026, why one macOS matrix leg can dominate the bill, and the YAML changes that move the number.
CircleCI Best Practices in 2026: Fast, Safe Pipelines
A production-focused CircleCI guide: orbs, reusable commands and executors, workflows with fan-in/fan-out, contexts and OIDC for secrets, layered caching, test splitting, approval jobs, and dynamic config — with copy-paste examples.
How to Secure Your CI/CD Pipeline (DevSecOps)
Your pipeline holds the keys to production and signs off on everything you ship, so harden both the pipeline itself and the artifacts it builds.
You might have missed
Evergreen posts worth revisiting.