🔧 Error Fixes

Fix: Docker — exec format error


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

or

standard_init_linux.go: exec user process caused: exec format error

The container is trying to execute a binary that doesn’t match the CPU architecture, or a script is missing its shebang line.

Fix 1: Platform mismatch (ARM vs. x86)

Most common on Apple Silicon (M1/M2/M3) Macs. The image was built for linux/amd64 but you’re running on linux/arm64.

# ❌ Image built for wrong platform
docker run myimage

# ✅ Force the platform
docker run --platform linux/amd64 myimage

# ✅ Or build for the right platform
docker build --platform linux/arm64 -t myimage .

# ✅ Build for both
docker buildx build --platform linux/amd64,linux/arm64 -t myimage .

Fix 2: Missing shebang in entrypoint script

# ❌ Script without shebang
echo "hello"

# ✅ Add shebang as first line
#!/bin/bash
echo "hello"

# ✅ Or for sh
#!/bin/sh
echo "hello"

Fix 3: Windows line endings

If you wrote the script on Windows, it might have \r\n line endings:

# Convert to Unix line endings
sed -i 's/\r$//' entrypoint.sh

# Or in Dockerfile
RUN sed -i 's/\r$//' /app/entrypoint.sh

Fix 4: Script not executable

# In Dockerfile
COPY entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh

See also: Docker cheat sheet | Docker image not found fix