Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect nodes of two docker containers in elixir?

I am trying to connect 2 nodes of different docker containers.

Container1: iex --name [email protected] --cookie foo

Container2: iex --name [email protected] --cookie foo

Now lets say I want to connect to [email protected] from [email protected]

Container2:

iex([email protected])> Node.connect(:"[email protected]")

iex([email protected])> true

Nodes are getting connected. But if I do

iex([email protected])> node  = "[email protected]"

iex([email protected])> Node.connect(:node)

iex([email protected])> false

Why I am getting error? This is happening with other functions as well such as Node.spawn/2.

like image 686
Sanket Achari Avatar asked Oct 18 '25 00:10

Sanket Achari


1 Answers

I got it working by converting the string into atom.

iex([email protected])> node  = "[email protected]"

iex([email protected])> Node.connect(String.to_atom(node))

iex([email protected])> true
like image 100
Sanket Achari Avatar answered Oct 19 '25 12:10

Sanket Achari