This post shows how to run Rocket.Chat in a docker cluster (swarm mode) starting from fresh Debian Jessie machines.

Rocket.Chat is a meteor app so other meteor apps are also run in similar way in swarm mode.

My cluster has 4 machines:

  • Manager 1: 172.16.43.248
  • Node 1: 172.16.43.230
  • Node 2: 172.16.43.133
  • Node 3: 172.16.43.136

Contents

  • Installing Docker 1.12
  • Configuring Swarm Mode
  • Setting up Rocket.Chat
  • Conclusion

Installing Docker 1.12

Install Docker engine on all machines:

export DEBIAN_FRONTEND=noninteractive ; \
apt-get update -y ;\
apt-get install -y -q apt-transport-https ;\
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D ;\
echo "deb https://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list ;\
apt-get update -y -q;\
apt-get upgrade -y -q;\
apt-get install -y -q docker-engine

Configuring Swarm Mode

On Manager 1:

docker swarm init --advertise-addr 172.16.43.248
# COPY SWARM JOIN COMMAND
docker info
docker network create --driver overlay my-net

The containers are using the my-net network to reach each others.

On Node 1,2,3, join the swarm:

docker swarm join --token SWMTKN-1-0plr12edz0xijk17oqh01rjg1jjopvpkwo5iztv608wcg408m1-cvm2x5ve0yhlesy2bso6s2rwl 172.16.43.248:2377

On Manager 1, check the node list:

docker node ls

The 4 nodes appear on the list.

Setting up Rocket.Chat

2 services are created: mongo (MongoDB) and chat (Rocket.Chat).

docker service create --replicas 1 --name mongo --network my-net mongo --smallfiles
docker service create --replicas 1 --name chat --network my-net --publish 3000:3000 rocketchat/rocket.chat

Now Rocket.Chat is available at any public address of the cluster due to routing and load balancing features of swarm mode: - http://172.16.43.248:3000 - http://172.16.43.230:3000 - http://172.16.43.133:3000 - http://172.16.43.136:3000

Scale Rocket.Chat:

docker service scale chat=3

Conclusion

Docker Swarm has improved a lot with version 1.12. The first thing is how fast it is to setup the cluster and then it is highly available, scalable and has rolling updating. I’m still leaning towards Kubernetes because of its superior, more stable concepts and more fine-grained specifications.