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.
exec /usr/local/bin/docker-entrypoint.sh: exec format error
# 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`?
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.
Related Developer Error Solutions
Browse All 54 GuidesDocker: Bind for 0.0.0.0:Port Failed
Identify and terminate conflicting host processes or adjust Docker port mapping to resolve port bind collisions.
Docker Compose: the attribute `version` is obsolete
Modernize `compose.yaml` to the Compose Specification and fix `localhost` vs service-name networking between containers.
Kubernetes: CrashLoopBackOff
Debug and recover crashing Kubernetes pods caused by failed startup commands, missing secrets, or exit code 1.