DockerCoreOpsThoughtworksRazorpayAsked in DevOps engineer rounds
The container works on your laptop but fails in production with "exec format error". What happened?
The scenario
A developer built and pushed the image from an M2 MacBook. The production nodes are x86 EC2 instances.
Model answer
The image was built for the wrong CPU architecture: arm64 on the Mac, amd64 in production.
- Check with docker image inspect (Architecture) or docker manifest inspect.
- Fix: build in CI, not on laptops, or use docker buildx build --platform linux/amd64 (or a multi-arch image for both).
- The same error appears when a script has no shebang or has Windows line endings, so check that if the architecture matches.
Common mistakes
- Rebuilding on the same laptop without --platform
- Pushing images from developer machines to production registries