Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect erlang nodes on docker

I have two docker images containing a released elixir app.
I run these two dockers on my local machine.
And I'm trying to connect the two nodes.
How can i run the released app on a named node?
or - is there any other way to do that ?

like image 965
faigy langsam Avatar asked Oct 21 '25 20:10

faigy langsam


1 Answers

This is how you would do it without docker-compose for Erlang nodes.

1. Create the network

docker network create example

2. Start docker containers

Terminal 1

$ docker run --rm -it --name bar -h bar --net example erlang:19.3 /bin/bash
root@bar:/# erl -sname bar -setcookie example
Erlang/OTP 19 [erts-8.3.5.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.3.5.1  (abort with ^G)
(bar@bar)1>

Terminal 2

docker run --rm -it --name foo -h foo --net example erlang:19.3 /bin/bash
root@foo:/# erl -sname foo -setcookie example
Erlang/OTP 19 [erts-8.3.5.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.3.5.1  (abort with ^G)
(foo@foo)1>

3. Check connectivity

Terminal 1

(foo@foo)1> net_adm:ping(bar@bar).
pong

Terminal 2

(bar@bar)1> net_adm:ping(foo@foo).
pong

Getting a remote shell for a release running on a docker container

1. Start a bash shell in one of the two docker containers

docker exec -it foo /bin/bash

Where foo is the name for the docker container.

2. Start a remote shell

./rel/your_app/bin/your_app console

I assume you know the path to the release inside the container.

like image 159
juan.facorro Avatar answered Oct 23 '25 20:10

juan.facorro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!