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

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

## Root Cause

Pulling an AMD64 image on an ARM64 host (or vice versa) without using multi-arch support results in a binary that the host CPU cannot execute.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Docker 24.0.5 | active | — | — |
| Docker Desktop 4.22.0 | active | — | — |
| Node.js 16.20.0 | active | — | — |
| ARM64 Ubuntu 22.04 | active | — | — |
| AMD64 Debian 11 | active | — | — |

## Workarounds

1. **Specify the platform explicitly in docker run: 'docker run --platform linux/arm64 node:16' on an ARM64 host, or '--platform linux/amd64' on AMD64.** (95% success)
   ```
   Specify the platform explicitly in docker run: 'docker run --platform linux/arm64 node:16' on an ARM64 host, or '--platform linux/amd64' on AMD64.
   ```
2. **Use Docker Buildx to build for multiple architectures: 'docker buildx build --platform linux/amd64,linux/arm64 -t myapp:latest .'** (90% success)
   ```
   Use Docker Buildx to build for multiple architectures: 'docker buildx build --platform linux/amd64,linux/arm64 -t myapp:latest .'
   ```
3. **Pull a multi-arch manifest by using the official image that supports both architectures, e.g., 'FROM --platform=$BUILDPLATFORM node:16' in your Dockerfile.** (85% success)
   ```
   Pull a multi-arch manifest by using the official image that supports both architectures, e.g., 'FROM --platform=$BUILDPLATFORM node:16' in your Dockerfile.
   ```

## Dead Ends

- **Reinstalling Node.js in the Dockerfile using apt-get install nodejs** — The error is not about missing Node.js but about architecture mismatch; reinstalling the same architecture package yields the same issue. (90% fail)
- **Adding 'RUN chmod +x /usr/bin/node' to the Dockerfile** — The file already has execute permissions; the error is due to the ELF binary being compiled for a different CPU architecture, not permission issues. (95% fail)
- **Setting 'FROM node:16' instead of 'FROM node:16-alpine'** — Both variants may default to the same architecture unless explicitly tagged; the tag change does not fix the architecture mismatch. (60% fail)
