Connecting to a containerized node

Before we connect to the node, we have to expose the container ports that will be used to connect the nodes. Edit your docker-compose.dev.yml file and add the following:

$ cat docker-compose.dev.yml  # ...  app:    image: elixir_drip:dev    # ...    ports:      - 4000:4000
      - 4369      - 9001-9004    # ...

The 9001-9004 port range is the range on which EPMD will assign ports to new nodes. We will tell EPMD to respect this range by passing the inet_dist_listen_min and inet_dist_listen_max parameters when running Elixir, and also when starting the application release. To pass these parameters when running the release, we need to set the erl_opts option in the release configuration:

$ cat rel/config.exs  # ...environment :prod ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.