how: Simple distributed Erlang in docker containers

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how: Simple distributed Erlang in docker containers

Bengt Kleberg
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)
(n@gustav)1>  net_kernel:connect('n@kalle').
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)
(n@kalle)1> net_kernel:connect('n@gustav').
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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: how: Simple distributed Erlang in docker containers

Peter Morgan
Hello -

Shell A:

docker run -it --rm erlang bash
root@cdcef8dbdcdd:/# ip addr show dev eth0
794: eth0@if795: <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 a@172.17.0.7 -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)
(a@172.17.0.7)1>


Shell B:

docker run -it --rm erlang bash
796: eth0@if797: <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 b@172.17.0.8 -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)
(b@172.17.0.8)1> net_adm:ping('a@172.17.0.7').
pong
(b@172.17.0.8)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 <[hidden email]> 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)
> (n@gustav)1>  net_kernel:connect('n@kalle').
> 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)
> (n@kalle)1> net_kernel:connect('n@gustav').
> 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
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: how: Simple distributed Erlang in docker containers

Bengt Kleberg
Thank you for showing a way forward.


Since "-name [hidden email]" is undocumented, I wonder if there is another
possibility to use distributed Erlang with Docker?


bengt

On 05/16/2016 05:30 PM, Peter Morgan wrote:

> Hello -
>
> Shell A:
>
> docker run -it --rm erlang bash
> root@cdcef8dbdcdd:/# ip addr show dev eth0
> 794: eth0@if795: <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 a@172.17.0.7 -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)
> (a@172.17.0.7)1>
>
>
> Shell B:
>
> docker run -it --rm erlang bash
> 796: eth0@if797: <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 b@172.17.0.8 -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)
> (b@172.17.0.8)1> net_adm:ping('a@172.17.0.7').
> pong
> (b@172.17.0.8)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 <[hidden email]> 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)
>> (n@gustav)1>  net_kernel:connect('n@kalle').
>> 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)
>> (n@kalle)1> net_kernel:connect('n@gustav').
>> 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
>> [hidden email]
>> http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: how: Simple distributed Erlang in docker containers

Chandru-4
On 17 May 2016 at 08:01, Bengt Kleberg <[hidden email]> wrote:
Thank you for showing a way forward.


Since "-name [hidden email]" is undocumented, I wonder if there is another possibility to use distributed Erlang with Docker?



Why do you say it is undocumented? From http://erlang.org/doc/man/erl.html

-name Name

Makes the Erlang runtime system into a distributed node. This flag invokes all network servers necessary for a node to become distributed. See net_kernel(3). It is also ensured that epmd runs on the current host before Erlang is started. See epmd(1).

The name of the node will be Name@Host, where Host is the fully qualified host name of the current host. For short names, use the -sname flag instead.


Chandru

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: how: Simple distributed Erlang in docker containers

Bengt Kleberg
Since the original message has been removed it is difficult to explain what I mean with undocumented. But interested parties can look it up. Especially the "Name" argument, that included an IP address. The resulting behaviour is very useful if the computer has been configured in a way where Erlang/OTP can not find out the fully qualified host name. But I have not seen this documented.


bengt

On 05/17/2016 10:31 PM, Chandru wrote:
On 17 May 2016 at 08:01, Bengt Kleberg <[hidden email]> wrote:
Thank you for showing a way forward.


Since "-name [hidden email]" is undocumented, I wonder if there is another possibility to use distributed Erlang with Docker?



Why do you say it is undocumented? From http://erlang.org/doc/man/erl.html

-name Name

Makes the Erlang runtime system into a distributed node. This flag invokes all network servers necessary for a node to become distributed. See net_kernel(3). It is also ensured that epmd runs on the current host before Erlang is started. See epmd(1).

The name of the node will be Name@Host, where Host is the fully qualified host name of the current host. For short names, use the -sname flag instead.


Chandru


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions