godmaire

godmaire

Erlexec not found when running app in Docker

Just started working with Elixir a month or so ago and am trying to package an application in Docker for the first time. It builds perfectly fine, but it crashes when ran with the following error:

/opt/sergei/releases/0.1.0/../../erts-13.1.3/bin/erl: exec: line 12: /opt/sergei/erts-13.1.3/bin/erlexec: not found

I’ve shelled into the docker container; the file does exist.

Here’s my Dockerfile

FROM elixir:alpine AS build_stage

# Config
ENV MIX_ENV prod
WORKDIR /opt/build

# Dependendies
COPY mix.* ./
COPY config ./config

RUN mix local.hex --force && \
  mix local.rebar --force && \
  mix deps.get --only prod && \
  mix deps.compile

# Build project
COPY . .
RUN mix release sergei

FROM alpine:latest

WORKDIR /opt/sergei
COPY --from=build_stage /opt/build/_build/prod/rel/sergei /opt/sergei

ENTRYPOINT ["/opt/sergei/bin/sergei"]
CMD ["start"]

Marked As Solved

ollien

ollien

I think I know the problem here. alpine uses musl OOTB, while most others use glibc. I cannot reproduce your problem exactly (the only way I was able to do so was by setting the build_stage FROM to elixir, which is actually Debian based), however, in that situation, I was able to do some poking. If I strace erlexec – since as you point out, it does exist – I see the following

execve("/opt/elixir_hello_world/erts-13.1.4/bin/erlexec", ["/opt/elixir_hello_world/erts-13."...], 0x7ffd6d09ac30 /* 6 vars */) = -1 ENOENT (No such file or directory)

Looking at the man page for execve, ENOENT can actually be returned under two situations. One, if the executable doesn’t exist, or two, if the loader doesn’t exist for that ELF binary (see here c - execve file not found when stracing the very same file! - Stack Overflow).

What I suspect is going on (but is hard to pin down given I can’t fully recreate your problem) is that glibc is being brought into your container somehow (are you perhaps copying _build from your local machine when you build the release? it may be worth adding that to .dockerignore), which is causing you problems when you move onto a glibc-less system (i.e. alpine:latest). When I build the release on elixir:alpine, I see that erlexec is correctly linked to libmusl

/opt/elixir_hello_world/erts-13.1.4/bin # ldd erlexec
	/lib/ld-musl-x86_64.so.1 (0x7faa179c8000)
	libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7faa179c8000)

Also Liked

godmaire

godmaire

This was the issue, thank you so much!

ventsyv

ventsyv

After some research, it appears that the alpine binaries are just not compatible with not alpine distros. I switched to compiling the app from source using elixir:latest (and updating node and npm) instead of trying to copy the compiled app from the alpine image.

This seems to have solved the problem.

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement