# exec /usr/bin/python3: exec format error

- **ID:** `docker/exec-format-error-arm64`
- **Domain:** docker
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

The container image is built for a different CPU architecture (e.g., amd64) than the host (e.g., arm64), causing the binary's ELF format to be incompatible.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Docker 25.0.0 | active | — | — |
| containerd 1.7.10 | active | — | — |
| Linux 6.5.0-arm64 | active | — | — |

## Workarounds

1. **Pull the correct architecture image: 'docker pull --platform linux/arm64 python:3.12-slim'. For multi-arch builds, use 'docker buildx build --platform linux/arm64 -t myapp .'** (95% success)
   ```
   Pull the correct architecture image: 'docker pull --platform linux/arm64 python:3.12-slim'. For multi-arch builds, use 'docker buildx build --platform linux/arm64 -t myapp .'
   ```
2. **Install QEMU user static binaries for emulation: 'docker run --privileged --rm tonistiigi/binfmt --install all'. Then run the amd64 image with 'docker run --platform linux/amd64 ...'** (85% success)
   ```
   Install QEMU user static binaries for emulation: 'docker run --privileged --rm tonistiigi/binfmt --install all'. Then run the amd64 image with 'docker run --platform linux/amd64 ...'
   ```

## Dead Ends

- **Reinstall Docker on the host** — Reinstallation does not change the CPU architecture mismatch between image and host. (95% fail)
- **Add '--platform linux/amd64' to docker run** — Forcing amd64 on an arm64 host without binfmt_misc or QEMU setup will still fail if the binary is not emulated. (80% fail)
- **Update Python inside the container via pip** — The error is at the binary execution level, not Python version; pip cannot fix ELF format. (90% fail)
