Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/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?
like image 810
Rieder Avatar asked Aug 03 '21 04:08

Rieder


People also ask

What does “error /Lib/LD-Linux so 2” mean?

For the case where it says “ERROR: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory”, ld-linux.so is an ELF dynamic linker or loader that is part of the operating system to load and link the shared libraries needed by the application.

How to fix “Bad Elf interpreter no such file or directory” error?

The error “bad ELF interpreter: No such file or directory” usually occurs because we tried to run a 32-bit application on a 64-bit operating system but our OS doesn’t have the support libraries to run 32-bit applications. To solve this problem, we need to download and install the packages that the 64-bit OS needs for running 32-bit applications.

What is /Lib/LD-Linux?

Installing Support Libraries for 32-Bit Applications For the case where it says “ERROR: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory”, ld-linux.so is an ELF dynamic linker or loader that is part of the operating system to load and link the shared libraries needed by the application.

Why is my 32-bit binary not running on a 64-bit system?

Your problem is a variant of Getting "Not found" message when running a 32-bit binary on a 64-bit system: you have an executable that mentions a dynamic loader that is not there. In your case, the dynamic loader /lib/ld-linux-x86-64.so.2 exists but in a different location /lib64/ld-linux-x86-64.so.2.


3 Answers

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>
like image 192
misnomer Avatar answered Oct 24 '22 09:10

misnomer


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

services:
  my-app:
    platform: linux/x86_64
like image 20
Taku Avatar answered Oct 24 '22 08:10

Taku


No idea what you are running in your container but for me, the reason was simply because a package (Prisma https://github.com/prisma/prisma/issues/8478#) did not find openssl packages and installing them on alpine image failed even with openssl manually installed.

It was fixed by switching to slim image and installing openssl with apt-get update && apt-get -y install openssl. I highly recommend not changing your platform since with my M1 the build time increased by 200s using linux/x86_64.

like image 2
TeemuK Avatar answered Oct 24 '22 09:10

TeemuK