I have two separate docker-compose.yml files, one for two clustered frontend nodes and docker-compose.yml for a “server” node that I wish to ADD as a node to the libcluster nodes.
I fire-up the server node first(via docker-compose up), where in application.ex I put:
Node.start(:"server@127.0.0.1")
Node.set_cookie(:foobar)
(I do not configure libcluster in the server app… perhaps this is the issue?)
then I start-up the frontend nodes via docker-compose.
The frontend libcluster config in runtime.exs:
config :libcluster,
topologies: [
example: [
strategy: Cluster.Strategy.Epmd,
config: [hosts: [:"app@foo.dev", :"app@bar.dev", :"server@127.0.0.1"]],
connect: {:net_kernel, :connect_node, []},
disconnect: {:erlang, :disconnect_node, []},
list_nodes: {:erlang, :nodes, [:connected]},
]
]
But the message I get in the frontend nodes on docker-compose up
is:
app2_1 | 17:37:03.675 [warning] [libcluster:example] unable to connect to :"server@127.0.0.1"
app1_1 | 17:37:03.673 [warning] [libcluster:example] unable to connect to :"server@127.0.0.1"
both docker-compose have:
networks:
proxy-network:
external: true
(So I’m assuming that libcluster should be able to find the other nodes via the docker network)
When I try:
network_mode: "host"
ports: [4000:4000]
with the “server” node, I get:
"host" network_mode is incompatible with port_bindings
So I am thinking that this means that I don’t need “host” network_mode because I have a docker network(?)
Still not sure why the frontend nodes cannot see the “server” node. Of course this is based on the assumption that they should see each other over libcluster. (EDIT: As I’m writing this, I realize that do not configure libcluster in the server app… perhaps this is the issue?) Any ideas?