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 ?
This is how you would do it without docker-compose
for Erlang nodes.
docker network create example
$ 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>
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>
(foo@foo)1> net_adm:ping(bar@bar).
pong
(bar@bar)1> net_adm:ping(foo@foo).
pong
bash
shell in one of the two docker containers docker exec -it foo /bin/bash
Where foo
is the name for the docker container.
./rel/your_app/bin/your_app console
I assume you know the path to the release inside the container.
Use docker-compose .
Something like this:
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 are able to point DNS elixir1
and elixir2
with that names among them.
Replace your docker run
commands with:
docker-compose up
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.