4

I've got an Elixir application running inside a Docker container (in my laptop). The Elixir application was executed with the following command:

iex \
  --name test@1.2.3.4 \
  --cookie secret \
  --erl '-kernel inet_dist_listen_min 9000'  \
  --erl '-kernel inet_dist_listen_max 9000' \
  -S mix phx.server

And the Docker container exposes the following ports:

0.0.0.0:4000->4000/tcp, 0.0.0.0:4369->4369/tcp, 0.0.0.0:9000->9000/tcp

  • 4000 for the Phoenix server
  • 4369 for EPMD
  • 9000 for the VM node

Then I try to connect using an IEx shell using the following command:

iex --name local@127.0.0.1 --cookie secret which results in this error: Protocol 'inet_tcp': register/listen error: epmd_close

This seems to be because the local epmd daemon is trying to allocate to port 4369, however, this is already allocated to the Docker container.

I then changed the EPMD port like so:

ERL_EPMD_PORT=4370 iex --name local@127.0.0.1 --cookie secret

and I manage to open up the IEx session. However, I cannot find the node running on the Docker container:

iex(local@127.0.0.1)1> Node.connect :'test@1.2.3.4'
false

I'm not sure how to solve this. I was following this blog post.

  • Why is this off-topic? (I'm having the same problem, btw. for ~16 hours. @sasha, did you ever solve the problem?) – Erhannis Jun 11 '21 at 05:04
  • AHA! In my case, I fixed it by adding the docker IP to the host's /etc/hosts file, named the container id. So like, `[container IP][container ID]`, e.g. `192.168.54.22 d0dce39944`. I was following https://toranbillups.com/blog/archive/2019/04/20/attach-iex-to-running-elixir-inside-docker-container/ otherwise. – Erhannis Jun 16 '21 at 03:43

0 Answers0