Reputation: 1435
Background
I am using docker to do a school project. Specifically, I pulled an ubuntu image and here is the system config:
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:
Upvotes: 102
Views: 133477
Reputation: 15726
In a variation of this, I was using alpine:latest
instead of ubuntu.
What worked for me was adding libc6-compat
to my Dockerfile:
RUN apk add libc6-compat
Alpine uses musl which was "designed from the ground up for static linking". But /lib64/ld-linux-x86-64.so.2
is a dynamic linking library from gcc/glibc.
Now my app works fine in alpine on my Apple Silicon Mac without the rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
error
Upvotes: 6
Reputation: 5540
Completing @misnomer answer, I could not even build the image.
If that is the case just add FROM --platform=linux/x86_64 ...
, from this source. Ex: FROM --platform=linux/x86_64 python:slim ...
Upvotes: 5
Reputation: 2519
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
.
Upvotes: 4
Reputation: 5918
For docker-compose, add platform: linux/x86_64
according to the docs
services:
my-app:
platform: linux/x86_64
Upvotes: 39
Reputation: 2594
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>
Upvotes: 207