<div dir="ltr">Hi<div><br></div><div>I am learning Distributed programming and in order to work through it, I started 2 docker containers using images provided by Mark Nijhof (<a href="https://github.com/MarkNijhof/erlang_docker">https://github.com/MarkNijhof/erlang_docker</a>)</div><div><br></div><div>So now when I start my docker containers (on same Macbook), I observe that they are not able to talk to each other </div><div><br></div><div><b>Server</b></div><div><p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">root@387bc0fe92dd:/code# erl -sname gru -setcookie abc</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54);min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">Eshell V6.0 (abort with ^G)</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">(gru@387bc0fe92dd)1> kvs:start().</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">true</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">(gru@387bc0fe92dd)2> </p></div><div><br></div><div><b>Minion</b></div><div><p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)"><span style="color:rgb(132,156,163)">➜ </span><span style="color:rgb(177,191,191)">erlang_docker </span><span style="color:rgb(165,182,184)">git:(</span><span style="color:rgb(254,119,63)">master</span><span style="color:rgb(165,182,184)">) </span>docker run -t -i erlang-build-box /bin/bash</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">root@035fe95388df:/# mkdir code</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">root@035fe95388df:/# cd code</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">root@035fe95388df:/code# vi kvs.erl</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">root@035fe95388df:/code# erl -sname minion1 -setcookie abc</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54);min-height:15px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">Eshell V6.0 (abort with ^G)</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">(minion1@035fe95388df)1> rpc:call(gru@387bc0fe92dd, kvs, store, [weather, fine]).</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">{badrpc,nodedown}</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">(minion1@035fe95388df)2> rpc:call(gru@387bc0fe92dd, kvs, store, [weather, fine]).</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">{badrpc,nodedown}</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">(minion1@035fe95388df)3> c(kvs).</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">{ok,kvs}</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">(minion1@035fe95388df)4> rpc:call(gru@387bc0fe92dd, kvs, store, [weather, fine]).</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">{badrpc,nodedown}</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">(minion1@035fe95388df)5> </p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54);min-height:15px"><br></p></div><div><b><br></b></div><div>My code looks like following and it works correctly when both server and minion are on same node</div><div><br></div><div><div>-module(kvs).<br></div><div>-author("harith").</div><div><br></div><div>%% API</div><div>-export([start/0, store/2, lookup/1]).</div><div><br></div><div>start() -></div><div> register(kvs, spawn(fun() -> loop() end)).</div><div><br></div><div>store(Key, Value) -></div><div> rpc({store, Key, Value}).</div><div><br></div><div>lookup(Key) -></div><div> rpc({lookup, Key}).</div><div><br></div><div>rpc(Q) -></div><div> kvs ! {self(), Q},</div><div> receive</div><div> {kvs, Reply} -></div><div> Reply</div><div> end.</div><div><br></div><div>loop() -></div><div> receive</div><div> {From, {store, Key, Value}} -></div><div> put(Key, {ok, Value}),</div><div> From ! {kvs, true},</div><div> loop();</div><div> {From, {lookup, Key}} -></div><div> From ! {kvs, get(Key)},</div><div> loop()</div><div> end.</div></div><div><br></div><div><br></div><div>What am I missing here?</div><div><br></div><div>Thanks</div><div>+ Harit</div></div>