[erlang-questions] how: Simple distributed Erlang in docker containers

Peter Morgan <>
Mon May 16 17:30:57 CEST 2016


Hello -

Shell A:

docker run -it --rm erlang bash
:/# ip addr show dev eth0
794: : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:07 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.7/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:7/64 scope link 
       valid_lft forever preferred_lft forever

erl -name  -setcookie abc
Erlang/OTP 18 [erts-7.3.1] [source] [64-bit] [smp:6:6] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.3.1  (abort with ^G)
()1> 


Shell B:

docker run -it --rm erlang bash
796: : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:08 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.8/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:8/64 scope link 
       valid_lft forever preferred_lft forever

erl -name  -setcookie abc
Erlang/OTP 18 [erts-7.3.1] [source] [64-bit] [smp:6:6] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.3.1  (abort with ^G)
()1> net_adm:ping('').
pong
()2> 


Take a look at the "--add-host=“ parameter to docker run, rather than modifying /etc/hosts.

Thanks
Peter.


> On 16 May 2016, at 13:58, Bengt Kleberg <> wrote:
> 
> Greetings,
> 
> What is needed to get two Erlang nodes talking if they are in Docker containers (on the same machine)?
> net_kernel:connect/1 fails.
> 
> 
> I have started 2 Docker containers (kalle and gustav) and it is possible to do
> ping kalle
> PING kalle.asd.se (172.17.0.4) 56(84) bytes of data.
> 64 bytes from kalle.asd.se (172.17.0.4): icmp_seq=1 ttl=64 time=0.137 ms
> 
> and
> ping gustav
> PING gustav.asd.se (172.17.0.5) 56(84) bytes of data.
> 64 bytes from gustav.asd.se (172.17.0.5): icmp_seq=1 ttl=64 time=0.147 ms
> 
> 
> Starting Erlang like this:
> erl -sname n -setcookie asd
> Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]
> 
> Eshell V6.3  (abort with ^G)
> ()1>  net_kernel:connect('').
> false
> 
> and, from the other side:
> erl -sname n -setcookie asd
> Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:4:4] [async-threads:10] [kernel-poll:false]
> 
> Eshell V6.3  (abort with ^G)
> ()1> net_kernel:connect('').
> false
> 
> 
> bengt
> (*) I manually added them to their respective /etc/hosts. If there is a way to do it automatically I would like to know.
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list