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.
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.
Verify the image architecture matches your host:
# 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.
If the architecture does not match, pull the correct variant:
# 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).
If you control the image, build for multiple architectures:
# 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.
If the error is about a script, ensure it has a proper shebang:
#!/bin/bash
# or
#!/bin/shThe shebang must be the very first line, with no spaces before it. Also verify the interpreter exists in the container.
Scripts created on Windows may have CRLF line endings. Convert them:
# 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.shEnsure scripts are executable:
# In Dockerfile
COPY --chmod=755 entrypoint.sh /entrypoint.sh
# Or run chmod
RUN chmod +x /entrypoint.shApple 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.
Container exited with code 128: invalid exit argument
How to fix 'Container exited with code 128' in Docker
Error response from daemon: Get https://registry-1.docker.io/v2/: Proxy Authentication Required
How to fix 'Proxy Authentication Required' in Docker
error exporting cache: failed to export cache
How to fix 'error exporting cache: failed to export cache' in Docker
net/http: TLS handshake timeout
How to fix 'net/http: TLS handshake timeout' in Docker
Docker container exited with code 255
How to fix 'Container exited with code 255' in Docker