docker platform ai_generated true

exec format error: exec user process caused: exec format error

ID: docker/docker-exec-format-error

Also available as: JSON · Markdown
88%Fix Rate
92%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
27 active

Root Cause

The container binary is compiled for a different CPU architecture than the host (e.g., running an amd64 image on arm64), or the entrypoint script lacks a proper shebang line.

generic

Workarounds

  1. 92% success Pull the image for the correct platform architecture
    docker pull --platform linux/amd64 <image> (or linux/arm64 depending on your host). Check host arch with: uname -m

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

  2. 90% success Add a proper shebang line to shell scripts used as entrypoints
    Ensure the first line of the script is #!/bin/sh (not #!/bin/bash if bash is not installed) and the file has execute permissions

    Sources: https://docs.docker.com/reference/dockerfile/#entrypoint

Dead Ends

Common approaches that don't work:

  1. Installing QEMU without registering binfmt_misc handlers 80% fail

    QEMU alone is not enough; the kernel needs binfmt_misc entries to know which emulator to use for foreign binaries

  2. Forcing the entrypoint to bash without checking if bash exists in the image 70% fail

    Many minimal images (alpine, scratch) do not include bash; use /bin/sh instead

Error Chain

Leads to:
Preceded by:
Frequently confused with: