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

Background

I am using docker to do a school project. Specifically, I pulled an ubuntu image and here is the system config:

enter image description here

I then logged into the docker container (ubuntu) and set up elasticsearch. When I try to run

./bin/elasticsearch

I get the following error inside the docker container's terminal

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

I have two main confusions:

  1. what does that even mean?
  2. How to solve it?


Solution 1:[1]

If you are running this on an M1 macbook, it's possible that you are running a native Arm image of ubuntu, instead of the emulated x86 image. If the elasticsearch distribution you are trying to install is for x86_64, then it attempts to link to the x86-64-native ld.so, which of course isn't present on different platforms.

Either install the package for the arm platform specifically if they provide one, or - more likely - run docker explicitly as the emulated x86_64 platform:

docker run --platform linux/x86_64 <image>

Solution 2:[2]

For docker-compose, add platform: linux/x86_64 according to the docs

services:
  my-app:
    platform: linux/x86_64

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 misnomer
Solution 2 Taku