DEV Community

Zahir Din
Zahir Din

Posted on

Docker Error: /lib64/ld-linux-x86-64.so.2: No such file or directory

When working with docker, sometimes we encounter an error we didn't expect. Sometimes it work on other machine but not yours. Docker help developer to run an application or system with same environment. It help reduce the "it work on my machine" stuff.

Unfortunately, it also depends on host machine we use. For example Windows OS using WSL to run docker, or MacBook M1 chip to run docker.

Some people might have encountered an error like this before:

qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Enter fullscreen mode Exit fullscreen mode

The error message encountered indicates that the /lib64/ld-linux-x86-64.so.2 file is missing inside the Docker container. This file is required for running x86_64 binaries on an x86_64 system.

To resolve this issue, you can try adding the libc6 package to the Docker image.

# Use the latest Ubuntu image as the base
FROM ubuntu:latest

# Install necessary dependencies
RUN apt-get update && apt-get install -y libc6

# Do something here...
Enter fullscreen mode Exit fullscreen mode

If you don't want to install any package inside a container, other approach is to run it as other platform. We can use it like this:

docker build --platform=linux/amd64 -t my_name/my_image .
Enter fullscreen mode Exit fullscreen mode

There is also other solution and that was to add --platform=linux/amd64 to the FROM line of the docker file.

FROM --platform=linux/amd64 ubuntu:latest
Enter fullscreen mode Exit fullscreen mode

Thanks to the resource I've found here.

Top comments (0)