EthioDeploy
DocsPricingDomainsBlogToolsChangelog

Blog/Fix deploy errors

Docker exec format error from an Apple Silicon build

BS
Brook SolomonPublished November 15, 2026
Share on XShare on LinkedIn
exec format error

THE SHORT ANSWER

exec format error means the Linux kernel refused to run the container's program because it isn't in a format that machine can execute. The usual cause: the image was built on an Apple Silicon Mac, so it holds linux/arm64 binaries, and the server is x86-64 (linux/amd64). Rebuild for the server with docker buildx build --platform linux/amd64, or publish a multi-platform image for both. If the architectures already match, the program is probably a script without a #! line at the very top; a script saved with Windows line endings fails with "no such file or directory" instead.

What does exec format error mean?

The container exits the moment it starts, with one line in its logs:

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

The path is whatever your ENTRYPOINT or CMD starts, such as exec /app/server: exec format error. The container runtime (runc) asked the kernel to run that file and got ENOEXEC back. The execve(2) man page defines it: “An executable is not in a recognized format, is for the wrong architecture, or has some other format error that means it cannot be executed.”

That covers two different problems. “Wrong architecture” is the Apple Silicon case below. “Some other format error” is usually a script with no #! line. If you started the container yourself, Docker may also have warned you 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 platform strings vary by machine; the wording is the same. Docker's docs put the rule simply: you “can't run a linux/amd64 container on an arm64 host (without using emulation)”, and the reverse holds too.

How do I check the architectures?

Compare the image with the machine that runs it:

# on the server
uname -m
# x86_64   -> linux/amd64
# aarch64  -> linux/arm64

# a local image
docker image inspect --format '{{.Os}}/{{.Architecture}}' myapp:latest
# linux/arm64

# an image in a registry: lists every platform it was published for
docker buildx imagetools inspect registry.example.com/myapp:latest

On an Apple Silicon Mac, uname -m prints arm64. If the image says linux/arm64 and the server says x86_64, you've found it.

Why does a Mac build produce the wrong image?

Because Docker builds for the machine it runs on unless told otherwise. The docker buildx build reference: “The default value is the platform of the BuildKit daemon where the build runs.” On an M-series Mac that's linux/arm64. The image runs perfectly on your laptop, gets pushed to a registry, and fails the first time an x86-64 server pulls it.

How do I build for linux/amd64?

Pass the server's platform to the build:

docker buildx build --platform linux/amd64 -t registry.example.com/myapp:1.0 --push .

To make it the default for every command that takes --platform, set the DOCKER_DEFAULT_PLATFORM environment variable in your shell:

export DOCKER_DEFAULT_PLATFORM=linux/amd64

On a Mac this build runs under emulation. Docker Desktop supports that by default, with no configuration, but expect it to be slow. Docker's docs: “Emulation with QEMU can be much slower than native builds, especially for compute-heavy tasks like compilation and compression or decompression.”

Also look for a hard-coded platform in the Dockerfile. FROM --platform=linux/arm64 ... pins that stage to arm64 whatever you pass on the command line, and some base images are only published for one architecture; imagetools inspect on the base image shows which.

Can one image run on both?

Yes. A multi-platform image holds a variant per architecture, and Docker pulls the one that matches the host. Build both and push them under one tag:

docker buildx build --platform linux/amd64,linux/arm64 -t registry.example.com/myapp:1.0 --push .

This needs an image store that understands manifest lists. Per Docker's docs, Docker Desktop and Docker Engine 29.0+ use the containerd image store by default, so it works without setup. On older engines you can use a builder with the docker-container driver instead, but its images “aren't loaded into your Docker Engine image store”, so push them straight to a registry.

Cross-compile instead of emulating

For compiled languages, emulation is the slow path. Docker's docs show running the build stage on your own platform and letting the compiler target the other one, using the automatic BUILDPLATFORM, TARGETOS and TARGETARCH build arguments. Their Go example:

# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM golang:alpine AS build
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
COPY . .
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o server .

FROM alpine
COPY --from=build /app/server /server
ENTRYPOINT ["/server"]

The same mistake happens without Docker's help: a binary built with plain go build on a Mac is a macOS arm64 program, and copying it into a Linux image fails with exec format error. Build it with GOOS=linux GOARCH=amd64 go build, or build inside the Dockerfile as above.

The architectures match: is it a script without #!?

The other common cause has nothing to do with CPUs. execve only runs a binary or “a script starting with a line of the form: #!interpreter [optional-arg]”. An entrypoint script that starts with a comment, a blank line or straight into commands has no interpreter line, so the kernel refuses it with the same ENOEXEC. In your terminal the script probably ran fine, because shells like bash fall back to running such files as shell scripts. The container runtime doesn't.

Put the interpreter on the very first line, with nothing before it:

#!/bin/sh
set -e
# migrations, config, etc.
exec "$@"

Pick an interpreter the image has. Alpine-based images have /bin/sh but not /bin/bash, and a missing interpreter gives a different error, covered next.

no such file or directory for a file that exists

A script saved with Windows line endings fails with a confusing message instead of exec format error:

exec /entrypoint.sh: no such file or directory

The file exists. Its first line is #!/bin/sh followed by an invisible carriage return, so the kernel looks for an interpreter literally named /bin/sh\r. execve(2) lists that case under ENOENT: “path or a script or ELF interpreter does not exist.” Check for the \r:

head -1 entrypoint.sh | od -c
# 0000000   #   !   /   b   i   n   /   s   h  \r  \n

Fix it in the repo so it stays fixed. Git's gitattributes docs use exactly this example, then renormalize the files Git already has:

# .gitattributes
*.sh text eol=lf

git add --renormalize .
git commit -m "Use LF line endings for shell scripts"

As a stopgap you can strip the carriage returns in the Dockerfile with RUN sed -i 's/\r$//' /entrypoint.sh.

What happens on EthioDeploy?

EthioDeploy builds your image from the GitHub repo on its own build servers, which are x86-64 like the servers your app runs on. An image built on your Mac never gets there, so the usual Apple Silicon case can't happen. It can still come from the repo itself: a Dockerfile stage pinned with FROM --platform=linux/arm64, a base image only published for arm64, or a binary compiled on your Mac and committed. Remove the pin, pick a multi-platform base image, or build the binary in the Dockerfile.

With the Builder setting on Auto, a repo with a Dockerfile is built from it; otherwise the stack is detected and built for you, with no Dockerfile involved. The shebang and line-ending problems still apply to any script your ENTRYPOINT or CMD runs. See how deploys work for the Builder options and the port your app has to listen on.

Questions

The kernel couldn't execute the container's program. Usually the image was built for another CPU architecture, such as linux/arm64 on an Apple Silicon Mac running on an x86-64 server. Otherwise the program is a script without a #! interpreter line at the top.

Run docker buildx build --platform linux/amd64 -t your-image --push . or set DOCKER_DEFAULT_PLATFORM=linux/amd64. The build runs under emulation on the Mac, so it is slower than a native build.

For a local image, docker image inspect --format '{{.Os}}/{{.Architecture}}' image:tag. For an image in a registry, docker buildx imagetools inspect image:tag lists every platform it was published for. Compare it with uname -m on the server.

Yes. Build with --platform linux/amd64,linux/arm64 and push. The result is a multi-platform image, and each host pulls the variant for its own architecture.

It has Windows line endings, so the kernel looks for an interpreter named /bin/sh followed by a carriage return. Convert the file to LF and add *.sh text eol=lf to .gitattributes. The same message appears when the #! line names an interpreter the image doesn't have, such as /bin/bash on Alpine.

Sources

Checked on November 15, 2026:

  • Docker: Multi-platform builds
  • Docker: docker buildx build
  • Docker: docker buildx imagetools inspect
  • Docker: docker image inspect
  • Docker: CLI environment variables
  • Docker: Dockerfile reference
  • Linux man pages: execve(2)
  • Linux man pages: uname(1)
  • runc: internal/linux/linux.go
  • moby: daemon/create.go
  • Git: gitattributes
  • Go: Installing Go from source ($GOOS and $GOARCH)

Push a repo. Get a URL.

  • How deploys work
  • Deploy a Go app
  • Deploy a Node.js app
  • Troubleshooting deploys
Start free

Join the EthioDeploy Telegram

Release notes as they ship, plus deploy help from the team and other developers.

Join on Telegram
BS
WRITTEN BYBrook SolomonFounder, EthioDeploy

Brook Solomon founded EthioDeploy and builds its deploy pipeline, build servers and AI coding agent. The posts here come from errors seen in real deploys on the platform.

All posts by Brook →
On this page
  • What does exec format error mean?
  • How do I check the architectures?
  • Why does a Mac build produce the wrong image?
  • How do I build for linux/amd64?
  • Can one image run on both?
  • Cross-compile instead of emulating
  • The architectures match: is it a script without #!?
  • no such file or directory for a file that exists
  • What happens on EthioDeploy?
  • Questions
  • Sources
0% read

Keep reading

  • 53300

    Fix deploy errorsNov 17, 2026

    Postgres "too many connections" after deploy: how to fix it

    Postgres refuses new connections with "FATAL: sorry, too many clients already" (SQLSTATE 53300, too_many_connections) once every slot under max_connections is taken, and max_connections defaults to 100. After a deploy the usual cause is arithmetic: each process of your app opens its own pool (10 for node-postgres and Prisma 7, 15 for SQLAlchemy), you run several processes, and for a short time the old and the new copy of the app are both connected. Count connections in pg_stat_activity, make copies × processes × pool max fit under the limit with room to spare, release clients you check out, set idle_in_transaction_session_timeout, and put PgBouncer in front when the numbers can't fit.

  • NEXT_PUBLIC_*

    Fix deploy errorsNov 17, 2026

    NEXT_PUBLIC_ env variables undefined in production: causes and fixes

    A NEXT_PUBLIC_ variable is undefined in production when it wasn't set while next build ran. Next.js replaces every process.env.NEXT_PUBLIC_ reference with a fixed value during the build, so a variable added to the server afterwards changes nothing until you build again. The other usual causes are reading it dynamically (process.env[name] or a copy of process.env), a name without the NEXT_PUBLIC_ prefix in a Client Component, and one Docker image promoted across environments. For values that must change without a rebuild, read them on the server at request time and pass them down.

  • Invalid HTTP_HOST header

    Fix deploy errorsNov 15, 2026

    Django DisallowedHost and CSRF errors behind a proxy

    DisallowedHost means the request's Host header isn't in ALLOWED_HOSTS, so Django answers 400; add your production domain to the list. The CSRF 403 "Origin checking failed - https://... does not match any trusted origins" usually means Django thinks the request came over plain HTTP: the proxy ended HTTPS and forwarded it as HTTP, so Django expects an http:// origin and the browser sent https://. Set SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") when your proxy sets that header. Since Django 4.0, entries in CSRF_TRUSTED_ORIGINS must include the scheme, such as https://example.com.

EthioDeploy

Agentic first development and deployment, started in Ethiopia, built for developers everywhere.

Telegram community
Product
PricingAI coding agentAgent mode docsDomainsCLIFree backend hostingHosting in EthiopiaChangelog
Deploy guides
Next.jsNode.jsPythonSvelteKitTanStack StartAstroNuxtReact RouterHonoStrapiDjangoFastAPIFlaskStreamlitExpressNestJSLaravelRailsGoTelegram botDiscord botLovableBoltReplitv0Google AI StudioBase44Firebase StudioClaude Code & Cursor
Compare
vs Herokuvs Vercelvs Rendervs Railwayvs Fly.iovs Netlifyvs KoyebHeroku alternativesVercel alternativesNetlify alternativesRender alternativesRailway alternativesFly.io alternativesReplit alternativesPythonAnywhere alternativesDigitalOcean App Platform alternativesGlitch alternatives
Resources
DocsBlogFree toolsAboutSupportContactllms.txt
© 2026 EthioDeployPay by card in USD or bank transfer in ETBTermsPrivacy