ppikula / mongooseim-docker

Dockerized MongooseIM 1.5
http://github.com/esl/MongooseIM
Apache License 2.0
20 stars 13 forks source link

More than 2 containers, cannot add mim3 to cluster #8

Open oceylantr opened 6 years ago

oceylantr commented 6 years ago

Created mim1 with: sudo docker run -d -t -h mim1 --name mim1 mongooseim/mongooseim-docker success

Created mim2 with: sudo docker run -d -t -h mim2 --name mim2 --link mim1:mim1 -e CLUSTER_WITH=mim1 mongooseim/mongooseim-docker

Created mim3 with: sudo docker run -d -t -h mim3 --name mim3 --link mim1:mim1 -e CLUSTER_WITH=mim1 mongooseim/mongooseim-docker

All container up but when I go to Bash of mim1 with command: sudo docker exec -it mim1 bash and run: mongooseimctl mnesia info | grep "running db nodes"

I can just see mim1 and mim2 but no sign of mim3 at connected node list. I am trying these at Virtualbox - Ubuntu 16.04 - network host or NAT or completely on AWS platform, no change. Cannot add mim3

One point I can catch from several trials is; when I run below command at all containers; I can see port number is 9100 on mim1 & mim2 but randomly defined on mim3, like 43501 or some number like that, don't know why:

net_adm:names().

oceylantr commented 6 years ago

I found a workaround, may be a clue: started cluster with a new Bridged network with no extra feature:

sudo docker run --network=sophos_network -d -t -h mim1 --name mim1 mongooseim/mongooseim-docker sudo docker run --network=sophos_network --add-host=mim1:172.18.0.2 -d -t -h mim2 --name mim2 -e CLUSTER_WITH=mim1 mongooseim/mongooseim-docker sudo docker run --network=sophos_network --add-host=mim1:172.18.0.2 -d -t -h mim3 --name mim3 -e CLUSTER_WITH=mim1 mongooseim/mongooseim-docker

and Voila! sudo docker exec -it mim1 bash mongooseimctl mnesia info | grep "running db nodes" running db nodes = [mongooseim@mim3,mongooseim@mim2,mongooseim@mim1]

ppikula commented 6 years ago

I played a bit with it and I found out, that with links approach you need to add link to mim2 for the node3 as well. The following seems to work for me:

docker run -d -t -h mim1 --name mim1 mongooseim/mongooseim-docker
docker run -d -t -h mim2 --name mim2 --link mim1:mim1 -e CLUSTER_WITH=mim1 mongooseim/mongooseim-docker
docker run -d -t -h mim3 --name mim3 --link mim1:mim1  --link mim2:mim2 -e CLUSTER_WITH=mim1 mongooseim/mongooseim-docker

or completely on AWS platform

Are you using ECS for it? If so I think you can ditch links and use DNS based service discovery, check the following link: https://aws.amazon.com/blogs/compute/service-discovery-for-amazon-ecs-using-dns/

WARNING: This repo is not maintained for ~2 years, be aware it might use outdated Mongoose IM version. You can check their official image instead of this one.