docker platform_error ai_generated true

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

ID: docker/exec-format-error-platform

Also available as: JSON · Markdown
93%Fix Rate
92%Confidence
70Evidence
2021-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
24 active

Root Cause

The container image was built for a different CPU architecture than the host. Most commonly: arm64 image on amd64 host or vice versa, triggered by Apple Silicon Macs deploying to amd64 Linux servers.

generic

Workarounds

  1. 95% success Specify --platform in docker run or FROM line
    Add --platform linux/amd64 (or linux/arm64) to match your target deployment. In Dockerfile: 'FROM --platform=linux/amd64 node:20'. In docker run: 'docker run --platform linux/amd64 myimage'.

    Sources: https://docs.docker.com/build/building/multi-platform/

  2. 92% success Build multi-platform images with docker buildx
    Set up buildx: 'docker buildx create --use'. Build for both architectures: 'docker buildx build --platform linux/amd64,linux/arm64 -t myimage:latest --push .'. The correct architecture is automatically selected at pull time.

    Sources: https://docs.docker.com/build/building/multi-platform/

  3. 90% success Remove cached wrong-architecture image and re-pull with --platform
    Docker caches the first platform it pulls. Remove the old image: 'docker image rm <image>:<tag>'. Then pull fresh: 'docker pull --platform linux/amd64 <image>:<tag>'.

Dead Ends

Common approaches that don't work:

  1. Reinstalling the binary inside the container 92% fail

    The binary itself is compiled correctly — it is compiled for a different CPU architecture. Reinstalling fetches the same architecture-mismatched binary because the base image is the wrong platform.

  2. Adding chmod +x to the binary 95% fail

    This is a permissions fix. The error is about ELF binary architecture mismatch, not file permissions. The binary is executable, just not for this CPU instruction set.

  3. Setting DOCKER_DEFAULT_PLATFORM after the image is already pulled 78% fail

    DOCKER_DEFAULT_PLATFORM only affects future image pulls. The cached image is still the wrong architecture. You must remove the old image first.

Error Chain

Frequently confused with: