Running Rocket.chat with docker
In this post, I show how to run Rocket.chat meteor app in multiple setups.
Contents
-
On a single machine
-
In docker swarm
-
On a single machine with SSL TLS 1.2
-
In docker swarm with SSL TLS 1.2
1. On a single machine
- Run a mongo container and name it db.
- Run a rocket.chat container and link it to db with the name mongo, inside the rocket.chat container, the address http://mongo reaches the mongo container.
- The rocket.chat container is named chat and is binded to port 3000.
To access rocket.chat, enter the address: http://ip_address_of_the_machine_running_docker:3000/
docker run --name db -d mongo --smallfiles
docker run --name chat -p 3000:3000 --link db:mongo -d rocketchat/rocket.chat
To stop rocket.chat:
docker stop chat db
To restart rocket.chat:
docker start db
# wait a few seconds
docker start chat
2. In docker swarm
For docker swarm setup see this post.
My docker swarm manager has ip:port=172.16.43.199:3456 and the overlay network is named my-net.
- Run a mongo container connected to my-net and name it mongo, the address http://mongo reaches the mongo container.
- Run a rocket.chat container connected to my-net.
- The rocket.chat container is named chat and is binded to port 3000.
To access rocket.chat, enter the address: http://ip_address_of_the_machine_running_the_rocket_chat_container:3000/
docker -H tcp://172.16.43.199:3456 run -d --name=mongo --net=my-net mongo --smallfiles
docker -H tcp://172.16.43.199:3456 run --name chat -p 3000:3000 -d --net=my-net rocketchat/rocket.chat
To get the address of node running rocket.chat, run:
docker -H tcp://172.16.43.199:3456 ps
To stop rocket.chat:
docker -H tcp://172.16.43.199:3456 stop chat mongo
To restart rocket.chat:
docker -H tcp://172.16.43.199:3456 start mongo
# wait a few seconds
docker -H tcp://172.16.43.199:3456 start chat
3. On a single machine with SSL TLS 1.2
- Run a mongo container and name it db.
- Run a rocket.chat container and link it to db with the name mongo, inside the rocket.chat container, the address http://mongo reaches the mongo container.
- Run a stud container and link it to the rocket.chat with the name app.
The stud docker image used in this setup is remynoulin/stud.
To create a self signed certificate, run this:
mkdir certs
openssl req -x509 -new -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem
cat key.pem cert.pem > certs/ssl.pem
To access rocket.chat, enter the address: https://ip_address_of_the_machine_running_docker:3443/
docker run --name db -d mongo --smallfiles
docker run --name chat --link db:mongo -d rocketchat/rocket.chat
cd certs
docker run --name stud -p 3443:443 --link chat:app -v $(pwd):/opt/certs -d remynoulin/stud
To stop rocket.chat:
docker stop stud chat db
To restart rocket.chat:
docker start db
# wait a few seconds
docker start chat
docker start stud
4. In docker swarm with SSL TLS 1.2
For docker swarm setup see this post.
My docker swarm manager has ip:port=172.16.43.199:3456 and the overlay network is named my-net.
- Run a mongo container connected to my-net and name it mongo, the address http://mongo reaches the mongo container.
- Run a rocket.chat container connected to my-net.
- Run a stud container connected to my-net.
The stud docker image used in this setup is remynoulin/stud.
To create a self signed certificate, run this:
mkdir certs
openssl req -x509 -new -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem
cat key.pem cert.pem > certs/ssl.pem
To access rocket.chat, enter the address: https://ip_address_of_the_machine_running_the_rocket_chat_container:3443/
docker -H tcp://172.16.43.199:3456 run -d --name=mongo --net=my-net mongo --smallfiles
docker -H tcp://172.16.43.199:3456 run --name app -d --net=my-net rocketchat/rocket.chat
docker -H tcp://172.16.43.199:3456 run --name stud -p 3443:443 --net=my-net -d remynoulin/stud
docker -H tcp://172.16.43.199:3456 cp certs/ssl.pem stud:/opt/certs/ssl.pem
docker -H tcp://172.16.43.199:3456 start stud
To get the address of node running stud, run:
docker -H tcp://172.16.43.199:3456 ps
To stop rocket.chat:
docker -H tcp://172.16.43.199:3456 stop stud chat mongo
To restart rocket.chat:
docker -H tcp://172.16.43.199:3456 start mongo
# wait a few seconds
docker -H tcp://172.16.43.199:3456 start chat
docker -H tcp://172.16.43.199:3456 start stud