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 https://stackoverflow.com/questions/5234088/execve-file-not-found-when-stracing-the-very-same-file).

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

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
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
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
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
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
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
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement