Elixir 1.9 releases without erts in docker alpine: "init terminating in do_boot",{load_failed"


  • macOS 10.14.5
  • [Erlang] brew install erlang@21
  • [Elixir] kiex install 1.9.0-rc.0


  defp releases do
      redpack: [
        include_executables_for: [:unix],
        # include_erts: "/usr/local/opt/erlang@21/lib/erlang/erts-",
        include_erts: false,
        applications: [runtime_tools: :permanent]


FROM bitwalker/alpine-erlang:21.3.8 ## erts-10.3.5
COPY .iex.exs .
COPY _build/prod/rel/myapp .

To reproduce

MIX_ENV=prod mix release
docker build --no-cache -t myapp:1.0.0 . -f docker/Dockerfile.build
docker run -it myapp:1.0.0 sh

/opt/app ;; bin/myapp start
{"init terminating in do_boot",{load_failed,[dtls_packet_demux,inet_tls_dist,dtls_handshake,tls_socket,tls_v1,tls_record,tls_sender,tls_handshake,tls_connection_sup,ssl_v3,ssl_srp_primes,ssl_record,tls_connection,ssl_sup,ssl_session_cache_api,ssl_session_cache,ssl_session,ssl_pkix_db,ssl_pem_cache,ssl_manager,ssl_handshake,ssl_listen_tracker_sup,ssl_dist_sup,ssl_dist_connection_sup,ssl_crl_cache_api,ssl_dist_admin_sup,ssl_crl_hash_dir,ssl_crl_cache,ssl_crl,ssl_cipher_format,ssl_connection_sup,ssl_connection,ssl_config,ssl_cipher,ssl_certificate,dtls_socket,ssl_app,ssl_alert,ssl_admin_sup,ssl,inet6_tls_dist,dtls_v1,dtls_record,dtls_listener_sup,dtls_connection_sup,dtls_connection]}}

It is like a compatibility issue, but when I type bin/myapp remote,it says

Erlang/OTP 21 [erts-10.3.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Could not contact remote node ;;;;, reason: :nodedown. Aborting...

And the erl version is also 10.3.5:

## in docker container
/opt/app ;; which erl
/opt/app # erl -v
Erlang/OTP 21 [erts-10.3.5] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Eshell V10.3.5  (abort with ^G)

It seems that the executables and the erl tool has the same version…

Can I build docker image in my mac directly without using another alpine? Since the mix release is very fast, but docker multistage is a bit slower :)

It looks like you are copying a locally built release to the docker image. You need to compile with identical setups as where it will run. I.E. use a staged docker build in your Dockerfile to build in the image, then copy the release to a new instance of the image without any cruft (or just do it all in the same image if you don’t care about it’s size). :slight_smile:

EDIT: Just for note, nothing at machine code level you compile on any system will really work in an alpine container, that includes the beam, for multiple reasons but the basic of which is that the alpine container doesn’t include libc, it uses something else (musl or so?). You need to compile from ‘within’ the docker container.