Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Docker on Apple silicon: qemu-x86_64 could not open /lib64/ld-linux-x86-64.so.2

Errorqemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

Short 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.

  • Applies to Docker Desktop 4.x on Apple silicon, Docker Buildx 0.2x, macOS 15
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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" Dockerfile
  2. 2Match what you see, then jump to its fix

    1. 1uname -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. 2You 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. 3docker 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

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:test

Confirmed by docs.docker.com

Did this fix it?

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 flags

2Fix

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 -m

Confirmed by docs.docker.com

Did this fix it?

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.0

Confirmed by docs.docker.com

Did this fix it?

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

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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.