[erlang-questions] Can't connect to Erlang node in docker

Magnus Henoch magnus@REDACTED
Wed Jun 5 16:06:14 CEST 2019


On 05/06/2019 13:10, Roger Lipscombe wrote:

> I've got an Erlang node running in docker[1]. How do I connect to it
> from the host?
>
> I've tried every combination of -name, -sname, etc., that I can think
> of, and all I'm getting is 'pang'.

You need a couple of things to succeed:

  * Both nodes must have the same cookie
  * The nodes must be using either both -name or both -sname; no mixing
    long and short names
  * The local node must use the exact same node name (including host
    name) that the remote node thinks it has
  * The local node must be able to resolve the host name part of the
    node name of the remote node

So if the remote node is running with node name foo@REDACTED, you
should be able to connect to it with erl -sname whatever -remsh
foo@REDACTED You can check the node name of the remote node by
looking at the prompt in the Erlang shell. Note that epmd only displays
the "local" part of the node name, not the host name, so you may be able
to open a connection to the remote node and still have it rejected and
closed if the host name part doesn't match.

If mycontainer doesn't resolve to the correct IP address, you can use an
inet configuration file: http://erlang.org/doc/apps/erts/inet_cfg.html
For example, to hard-code an IP address for a host name and force the
Erlang node to use this file instead of native name resolution:

{host, {10,1,2,3}, ["mycontainer"]}.
{lookup, [file]}.

Then pass the name of this file like this:

erl -sname whatever -remsh foo@REDACTED -kernel inetrc '"./myinetrc"'

Hope this helps,
Magnus


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190605/19617f41/attachment.htm>


More information about the erlang-questions mailing list