I have an executable created via
mix release which works just fine when I run it with
start on my local machine. However, my docker image crashes when trying to
start the executable and I don’t know why.
FROM elixir:1.10 # Install Hex + Rebar RUN mix do local.hex --force, local.rebar --force COPY . / WORKDIR / ENV MIX_ENV=prod RUN mix do deps.get --only $MIX_ENV, deps.compile RUN mix release EXPOSE 8080 ENV PORT=8080 ENV SHELL=/bin/bash CMD ["_build/prod/rel/my_app/bin/my_app", "start"]
This is my docker file. It does nothing special other than compiling and then trying to run the release via
However, when I execute the docker image with
docker run -p 8080:8080 my-app:1.0 docker crashes:
/_build/prod/rel/my_app/releases/0.1.0/../../erts-10.5/bin/erl: 12: exec: /_build/prod/rel/my_app/erts-10.5/bin/erlexec: Exec format error
At first I thought this was happening because the file
_build/prod/rel/my_app/bin/my_app was missing
#!/usr/bin/env bash at the top.
While indeed it doesn’t have that, it has something else that should equally work:
So this theory is out.
Another thing that may be possible is that, since this is the release of an umbrella app (in which there are 3 apps) maybe there is a race condition in launching the apps that is causing an internal error and makes the image crash.
However, I can’t confirm this.
Is something wrong with my Dockerfile?
How can I get rid this error?