Docker on Apple silicon: qemu-x86_64 could not open /lib64/ld-linux-x86-64.so.2
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directoryShort answer
The container is running an x86-64 program on an ARM machine through QEMU emulation, and the image's root has no x86-64 loader to hand to it. Usually a Dockerfile mixes an arm64 base image with amd64 files, or a stage was built for the wrong platform. Pin the platform, or build a native arm64 image.
Fix it fast
1Find out which cause you have
Compare the machine's architecture with what the image reports, and look at the platform in each FROM line.
uname -m docker image inspect IMAGE:TAG --format '{{.Os}}/{{.Architecture}}' grep -n -i "^FROM" Dockerfile2Match what you see, then jump to its fix
- 1
uname -m prints arm64, the image is linux/arm64, and the failing file is a prebuilt x86-64 binary (a downloaded tool, a jar launcher, a Go build for amd64)An amd64 binary was copied into an arm64 image (or the reverse)Fix - 2
You pass --platform linux/amd64 (or the base image is amd64-only) and RUN steps fail under emulationThe build runs for a platform the host can only emulate, and emulation is not workingFix - 3
docker image inspect shows linux/amd64 on an arm64 machine; some binaries run, others cannot find loaders or crashThe image is amd64-only, so every start goes through emulationFix
- 1
What does the error look like?
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Cause 1 of 3
An amd64 binary was copied into an arm64 image (or the reverse)
1Check
The base image is native, so QEMU is invoked only for the foreign binary and finds no x86-64 loader in the image's filesystem.
docker run --rm IMAGE:TAG sh -c 'uname -m; file /path/to/failing/binary'2Fix
Use the build for the platform the image has. When a Dockerfile cross-compiles, use the TARGETARCH build argument instead of hard-coding amd64.
FROM --platform=$BUILDPLATFORM golang:1.24 AS build
ARG TARGETOS
ARG TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/app .3Verify
Rebuild; the container starts without the qemu message.
docker build -t app:test . && docker run --rm app:testConfirmed by docs.docker.com
Cause 2 of 3
The build runs for a platform the host can only emulate, and emulation is not working
1Check
Docker Desktop uses its bundled QEMU. On plain Docker Engine the emulators have to be registered; the binfmt entries must show the F flag.
cat /proc/sys/fs/binfmt_misc/qemu-* 2>/dev/null | grep -i flags2Fix
Install the emulators with the command from the Docker docs, or build natively for arm64 so no emulation is needed.
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx build --platform linux/arm64 -t app:arm64 .3Verify
The build finishes and the image runs.
docker run --rm app:arm64 uname -mConfirmed by docs.docker.com
Cause 3 of 3
The image is amd64-only, so every start goes through emulation
1Check
Emulation is slower and less complete than running natively, and Docker's guidance is to prefer native builds or cross-compilation.
docker image inspect IMAGE:TAG --format '{{.Architecture}}'2Fix
Build and publish a multi-platform image so Apple silicon gets an arm64 variant.
docker buildx build --platform linux/amd64,linux/arm64 -t registry.example.com/app:1.0 --push .3Verify
The tag lists both platforms.
docker buildx imagetools inspect registry.example.com/app:1.0Confirmed by docs.docker.com
How do I stop it coming back?
- Never hard-code amd64 downloads in a Dockerfile; branch on TARGETARCH.
- Publish multi-platform images for anything team members run on laptops.
- Run uname -m inside the container as the first debugging step.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
A dev container port does not open in the browser when Docker runs on a remote host
If your application only accepts calls from localhost, it will reject connections from published ports
Three things usually break it: the app listens only on localhost inside the container, so published ports are rejected; you open the container port instead of the mapped localhost port VS Code shows; or you changed appPort or a Compose ports list and did not rebuild.
3 causes, each with a fix