Connect erlang nodes to docker
2 answers
This is how you can do it without docker-compose
for Erlang nodes.
1. Create a 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 the connection
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 in a docker container
1. Start a shell bash
in one of the two docker containers
docker exec -it foo /bin/bash
Where foo
is the name of the docker container.
2. Start the remote shell
./rel/your_app/bin/your_app console
I assume you know the release path inside the container.
+2
source to share
Use docker-compose .
Something like that:
docker-compose.yml:
version: "3"
services:
elixir1:
image: image-name
#(other configs here, like ports, volumes)
elixir2:
image: image-name
#(other configs here, like ports, volumes)
Then you can specify DNS elixir1
and elixir2
with those names among them.
Replace the commands docker run
with:
docker-compose up
+2
source to share