How to fix exec /usr/local/bin/docker-entrypoint.sh: exec format error in Docker

DockerINTERMEDIATEMEDIUMUpdated Dec 6, 2025ยท 313 views

The container binary or script cannot run on the current CPU architecture. This usually means an image built for a different architecture (e.g., ARM vs x86) or a script missing its shebang line.

Quick fix

Fixes exec /usr/local/bin/docker-entrypoint.sh: exec format error

# Check your host architecture
uname -m

# Check image architecture
docker inspect --format "{{.Architecture}}" <image_name>

# Or view manifest for multi-arch images
docker manifest inspect <image_name>
  1. Check image architecture
  2. Pull the correct architecture
  3. Build multi-architecture images
  4. Fix script shebang lines
docker โ€” error
# Check your host architecture
uname -m
# Check image architecture
docker inspect --format "{{.Architecture}}" <image_name>
# Or view manifest for multi-arch images
docker manifest inspect <image_name>
exec /usr/local/bin/docker-entrypoint.sh: exec format error

What this error means

This error occurs when Docker tries to execute a binary or script that is incompatible with the container runtime environment. The operating system cannot interpret the executable format. The most common cause is an architecture mismatch: trying to run an ARM64 image on an x86_64 host (or vice versa). This became more prevalent with Apple Silicon Macs (M1/M2/M3) which use ARM architecture.

Typical symptoms

  • Container exits immediately after starting
  • docker run fails with exec format error
  • Scripts that worked locally fail in the container
  • Image works on one machine but not another
  • Error occurs at container startup, not during build

Common causes

  1. Image built for different CPU architecture (ARM vs x86_64)
  2. Shell script missing shebang line (#!/bin/bash)
  3. Shebang points to non-existent interpreter in container
  4. Binary compiled for wrong architecture
  5. Using Apple Silicon Mac with x86-only images
  6. Windows line endings (CRLF) in shell scripts
  7. Corrupted or incomplete image pull

How to fix "exec /usr/local/bin/docker-entrypoint.sh: exec format error"

1Check image architecture

Verify the image architecture matches your host:

bash
# Check your host architecture
uname -m

# Check image architecture
docker inspect --format "{{.Architecture}}" <image_name>

# Or view manifest for multi-arch images
docker manifest inspect <image_name>

Common architectures: amd64 (x86_64), arm64 (aarch64), arm/v7.

2Pull the correct architecture

If the architecture does not match, pull the correct variant:

bash
# Pull specific architecture
docker pull --platform linux/amd64 <image_name>
docker pull --platform linux/arm64 <image_name>

# Run with platform flag
docker run --platform linux/amd64 <image_name>

Docker Desktop can emulate other architectures (slower but works).

3Build multi-architecture images

If you control the image, build for multiple architectures:

bash
# Enable buildx
docker buildx create --use

# Build for multiple platforms
docker buildx build --platform linux/amd64,linux/arm64 -t myimage:latest .

This creates a manifest that works on both architectures.

4Fix script shebang lines

If the error is about a script, ensure it has a proper shebang:

bash
#!/bin/bash
# or
#!/bin/sh

The shebang must be the very first line, with no spaces before it. Also verify the interpreter exists in the container.

5Fix Windows line endings

Scripts created on Windows may have CRLF line endings. Convert them:

bash
# Using dos2unix
dos2unix script.sh

# Or using sed
sed -i "s/\r$//" script.sh

# In Dockerfile, convert during build
RUN sed -i "s/\r$//" /entrypoint.sh
6Verify script permissions

Ensure scripts are executable:

bash
# In Dockerfile
COPY --chmod=755 entrypoint.sh /entrypoint.sh

# Or run chmod
RUN chmod +x /entrypoint.sh

Advanced notes

Apple Silicon Macs: Install Rosetta 2 for better x86 emulation: softwareupdate --install-rosetta. Docker Desktop uses QEMU for emulation, which is slower than native.

CI/CD Pipelines: If building on ARM runners (like GitHub Actions ARM), ensure you build multi-arch images or specify the correct platform.

Base Image Selection: Alpine-based images are smaller but may have different binary compatibility. If having issues, try a Debian-based image like node:20-slim instead of node:20-alpine.

Frequently asked questions

What does "exec /usr/local/bin/docker-entrypoint.sh: exec format error" mean?
This error occurs when Docker tries to execute a binary or script that is incompatible with the container runtime environment. The operating system cannot interpret the executable format. The most common cause is an architecture mismatch: trying to run an ARM64 image on an x86_64 host (or vice versa).
How do I fix "exec /usr/local/bin/docker-entrypoint.sh: exec format error"?
The container binary or script cannot run on the current CPU architecture. This usually means an image built for a different architecture (e.g., ARM vs x86) or a script missing its shebang line.
What causes "exec /usr/local/bin/docker-entrypoint.sh: exec format error"?
Image built for different CPU architecture (ARM vs x86_64) Shell script missing shebang line (#!/bin/bash) Shebang points to non-existent interpreter in container
Is the "exec /usr/local/bin/docker-entrypoint.sh: exec format error" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading