Skip to main content
DevOps & Docker · Developer Error Resolution Lab

Fix Docker 'exec /usr/local/bin/docker-entrypoint.sh: exec format error' (ARM64 vs AMD64)

Resolve CPU architecture mismatches when building Docker images on Apple Silicon (M1/M2/M3/M4 `linux/arm64`) and deploying to x86_64 (`linux/amd64`) cloud servers.

Triggered Error Message:

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

Customize Solution for Your Environment
# 1. Build specifically for x86_64 cloud servers:
docker buildx build --platform linux/amd64 -t myorg/api:latest --push .

# 2. If caused by entrypoint script on Windows, ensure LF line endings and #!/usr/bin/env sh shebang:
sed -i 's/\r$//' docker-entrypoint.sh
chmod +x docker-entrypoint.sh

Root Cause & Mechanism Analysis

Why does this error occur?

The container image was built for a different CPU instruction set (e.g., `linux/arm64` on a MacBook) than the target Linux host (`linux/amd64` on AWS ECS, EKS, or DigitalOcean), or a shell script entrypoint is missing its `#!/bin/sh` shebang or has Windows `CRLF` line endings.

Frequently Asked Questions

Can Windows CRLF line endings also cause `exec format error`?
Yes! If `docker-entrypoint.sh` has `#!/bin/sh\r\n`, the Linux kernel looks for `/bin/sh\r` and throws `exec format error` or `no such file or directory`.
DEVSECOPS & CI/CD PARTNER2 Slots Open

Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?

Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.

Browse All 54 Guides