Rocket.Chat is one of the leading open-source communication platforms for organizations that require high standards of data protection and customization capabilities. In this comprehensive guide, we’ll walk through how to deploy Rocket.Chat using Docker and Docker Compose, providing you with a robust, scalable, and secure chat solution that you can self-host.
I have been running it on multiple systems for years. Started with a local direct install and moved to Docker about 3 years ago. Running the latest release with MongoDB 6 at the moment, it had problems with MongoDB 7 last year and I am not switching yet. With Rocket.Chat 8.x, they will deprecate MongoDB 5.
Introduction to Rocket.Chat
Rocket.Chat is a fully customizable communications platform developed in JavaScript. It offers features like:
- Real-time chat with individual and group messaging
- File sharing and media embedding
- Voice and video calls
- Screen sharing
- Integration with popular services and third-party applications
- End-to-end encryption
- Self-hosting options for complete data control
Unlike proprietary solutions, Rocket.Chat gives you full control over your data and allows for extensive customization to match your organization’s specific needs.
System Requirements
Before installing Rocket.Chat, ensure your server meets the minimum requirements. Requirements vary based on your expected usage:
For Small Teams (up to 50 concurrent users)
- 2 vCPUs (minimum)
- 2GB RAM (minimum)
- 10GB of storage for MongoDB
- 3GB minimum disk space for the Rocket.Chat application
For Medium Deployments (50-500 concurrent users)
- 4 vCPUs
- 8GB RAM
- 40GB+ of storage for MongoDB
- 5GB+ disk space for the Rocket.Chat application
For Large Deployments (500-5000 concurrent users)
- 8+ vCPUs
- 16GB+ RAM
- 80GB+ of storage for MongoDB
- 10GB+ disk space for the Rocket.Chat application
For Enterprise Deployments (5000+ concurrent users)
- 16+ vCPUs
- 32GB+ RAM
- Custom MongoDB deployment with replication and sharding
- Specialized server architecture
Note: For file storage in production environments, Rocket.Chat recommends using object storage services such as Amazon S3, Google Cloud Storage, or MinIO instead of GridFS.
Prerequisites
Before proceeding with the installation, ensure you have:
- A server running Linux (Ubuntu Server 22.04 LTS recommended)
- Docker Engine installed (version 20.10 or newer)
- Docker Compose installed (version 2.0 or newer)
- A domain name pointing to your server’s IP address
- Ports 80 and 443 open in your firewall for HTTP/HTTPS access
Installing Docker and Docker Compose
If you don’t have Docker already installed, you can install it with:
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Add your user to the docker group to run docker without sudo
sudo usermod -aG docker $USER
sudo newgrp docker
# Install Docker Compose
sudo apt update
sudo apt install docker-compose-plugin
Verify the installations:
docker --version
docker compose version
Installation Methods
There are several approaches to deploy Rocket.Chat with Docker:
- Using the official Docker image with a simple docker run command
- Using Docker Compose with a basic configuration
- Using Docker Compose with Traefik for reverse proxy and automatic SSL
This guide focuses on the Docker Compose approach as it provides the best balance of simplicity and flexibility.
Setting Up with Docker Compose
We’ll use Docker Compose to set up Rocket.Chat with MongoDB (required database) and Traefik as a reverse proxy for handling SSL certificates.
Step 1: Create Project Directory
First, create a directory for your Rocket.Chat deployment:
mkdir ~/rocketchat
cd ~/rocketchat
Step 2: Create Docker Networks
Create the necessary Docker networks:
docker network create traefik-network
docker network create rocketchat-network
Step 3: Create .env File
Create a .env file to store environment variables:
nano .env
Add the following content, making sure to replace the example values with your own:
# Traefik Variables
TRAEFIK_IMAGE_TAG=traefik:3.2
# Set the log level (DEBUG, INFO, WARN, ERROR)
TRAEFIK_LOG_LEVEL=WARN
# The email address for Let's Encrypt certificate notifications
TRAEFIK_ACME_EMAIL=admin@yourdomain.com
# The hostname for the Traefik dashboard
TRAEFIK_HOSTNAME=traefik.chat.yourdomain.com
# Basic Authentication for Traefik Dashboard (username:hashed-password)
# Generate with htpasswd: htpasswd -nb admin secure_password
TRAEFIK_BASIC_AUTH=admin:$2y$10$sMzJfirKC75x/hVpiINeZOiSm.Jkity9cn4KwNkRvO7hSQVFc5FLO
# Rocket.Chat Variables
ROCKETCHAT_MONGODB_IMAGE_TAG=bitnami/mongodb:6.0
ROCKETCHAT_IMAGE_TAG=rocket.chat:6.10
ROCKETCHAT_URL=https://chat.yourdomain.com
ROCKETCHAT_HOSTNAME=chat.yourdomain.com
Step 4: Create Docker Compose File
Create a docker-compose.yml file:
nano docker-compose.yml
Add the following content:
networks:
rocketchat-network:
external: true
traefik-network:
external: true
volumes:
rocketchat-uploads:
rocketchat-mongodb:
traefik-certificates:
services:
mongodb:
image: ${ROCKETCHAT_MONGODB_IMAGE_TAG}
volumes:
- rocketchat-mongodb:/bitnami/mongodb
environment:
MONGODB_REPLICA_SET_MODE: primary
MONGODB_REPLICA_SET_NAME: rs0
MONGODB_PORT_NUMBER: 27017
MONGODB_INITIAL_PRIMARY_HOST: mongodb
MONGODB_INITIAL_PRIMARY_PORT_NUMBER: 27017
MONGODB_ADVERTISED_HOSTNAME: mongodb
MONGODB_ENABLE_JOURNAL: 'true'
ALLOW_EMPTY_PASSWORD: 'yes'
networks:
- rocketchat-network
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 3
start_period: 60s
restart: unless-stopped
rocketchat:
image: ${ROCKETCHAT_IMAGE_TAG}
volumes:
- rocketchat-uploads:/app/uploads
environment:
PORT: 3000
ROOT_URL: ${ROCKETCHAT_URL}
MONGO_URL: mongodb://mongodb:27017/rocketchat?replicaSet=rs0
MONGO_OPLOG_URL: mongodb://mongodb:27017/local?replicaSet=rs0
DEPLOY_METHOD: docker
Accounts_UseDNSDomainCheck: 'false'
networks:
- rocketchat-network
- traefik-network
healthcheck:
test: >
/usr/local/bin/node -e 'const http = require("http");const options = {host: "localhost",port: 3000,path: "/api/info",timeout: 2000};const healthCheck = http.request(options, (res) => {console.log(HEALTHCHECK STATUS: ${res.statusCode});if (res.statusCode == 200) {process.exit(0);} else {process.exit(1);}});healthCheck.on("error", function (err) {console.error("ERROR");process.exit(1);});healthCheck.end();'
interval: 10s
timeout: 5s
retries: 3
start_period: a120s
labels:
# Enable Traefik for this container
- "traefik.enable=true"
# Match incoming requests on a specific hostname
- "traefik.http.routers.rocketchat.rule=Host(${ROCKETCHAT_HOSTNAME})"
# Assign the router to a named Traefik service
- "traefik.http.routers.rocketchat.service=rocketchat"
# Use the 'websecure' (HTTPS) entry point
- "traefik.http.routers.rocketchat.entrypoints=websecure"
# Define the internal container port for routing
- "traefik.http.services.rocketchat.loadbalancer.server.port=3000"
# Enable TLS on this router
- "traefik.http.routers.rocketchat.tls=true"
# Use Let's Encrypt for certificate management
- "traefik.http.routers.rocketchat.tls.certresolver=letsencrypt"
# Pass the original Host header to the container
- "traefik.http.services.rocketchat.loadbalancer.passhostheader=true"
# Apply a compression middleware
- "traefik.http.routers.rocketchat.middlewares=compresstraefik"
# Define settings for the compression middleware
- "traefik.http.middlewares.compresstraefik.compress=true"
# Specify which Docker network Traefik should use for routing
- "traefik.docker.network=traefik-network"
restart: unless-stopped
depends_on:
mongodb:
condition: service_healthy
traefik:
condition: service_healthy
traefik:
image: ${TRAEFIK_IMAGE_TAG}
command:
# Set the log level (DEBUG, INFO, WARN, ERROR)
- "--log.level=${TRAEFIK_LOG_LEVEL}"
# Enable the built-in API and web-based dashboard
- "--api.dashboard=true"
# Enable the /ping endpoint so we can health-check Traefik
- "--ping=true"
# Assign the /ping endpoint to a dedicated entry point on port 8082
- "--ping.entrypoint=ping"
- "--entrypoints.ping.address=:8082"
# Define the primary HTTP entry point on port 80
- "--entrypoints.web.address=:80"
# Define the secure (HTTPS) entry point on port 443
- "--entrypoints.websecure.address=:443"
# Enable the Docker provider to detect containers and their labels
- "--providers.docker=true"
# Point Traefik to the Docker socket
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
# Prevent automatic exposure of all containers; only expose containers with "traefik.enable=true"
- "--providers.docker.exposedbydefault=false"
# Use ACME (Let's Encrypt) to generate/renew certificates via TLS challenge
- "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
# The email address used by Let's Encrypt for renewal notices
- "--certificatesresolvers.letsencrypt.acme.email=${TRAEFIK_ACME_EMAIL}"
# The file where ACME certificates are stored inside the container
- "--certificatesresolvers.letsencrypt.acme.storage=/etc/traefik/acme/acme.json"
# Enable Prometheus metrics
- "--metrics.prometheus=true"
# Configure Prometheus histogram buckets
- "--metrics.prometheus.buckets=0.1,0.3,1.2,5.0"
# Check for newer Traefik versions and optionally log that info
- "--global.checknewversion=true"
# Disable sending anonymous usage data to the Traefik maintainers
- "--global.sendanonymoususage=false"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-certificates:/etc/traefik/acme
networks:
- traefik-network
ports:
- "80:80"
- "443:443"
healthcheck:
test: ["CMD", "wget", "http://localhost:8082/ping","--spider"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
labels:
# Enable Traefik for this container
- "traefik.enable=true"
# A router to expose the Traefik dashboard
- "traefik.http.routers.dashboard.rule=Host(${TRAEFIK_HOSTNAME})"
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.routers.dashboard.tls=true"
- "traefik.http.routers.dashboard.tls.certresolver=letsencrypt"
- "traefik.http.routers.dashboard.service=api@internal"
# Basic Authentication for the Traefik dashboard
- "traefik.http.routers.dashboard.middlewares=authtraefik"
- "traefik.http.middlewares.authtraefik.basicauth.users=${TRAEFIK_BASIC_AUTH}"
# Specify the internal server port to the dashboard service
- "traefik.http.services.dashboard.loadbalancer.server.port=8080"
# Pass the original Host header to the backend
- "traefik.http.services.dashboard.loadbalancer.passhostheader=true"
# HTTP -> HTTPS redirect for all hosts
- "traefik.http.routers.http-catchall.rule=HostRegexp({host:.+})"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
restart: unless-stopped
Step 5: Deploy Rocket.Chat
Start the deployment with Docker Compose:
docker compose up -d
This command will:
- Pull the required Docker images
- Create necessary volumes
- Set up MongoDB with a replica set for Rocket.Chat
- Configure Traefik for HTTPS and reverse proxy
- Start the Rocket.Chat service
Step 6: Verify the Deployment
Check if the containers are running:
docker ps
You should see three containers running:
- MongoDB
- Rocket.Chat
- Traefik
Check the logs for any errors:
docker logs rocketchat_rocketchat_1
Post-Installation Steps
Setting Up the Admin Account
- Open your browser and navigate to your Rocket.Chat URL (https://chat.yourdomain.com)
- Follow the on-screen instructions to set up your admin account
- Create your organization profile
- Register your server (optional, but recommended for notifications)
Configuring SMTP for Email Notifications
To enable email notifications in Rocket.Chat:
- Log in with your admin account
- Go to Administration > Email > SMTP
- Fill in your SMTP server details:
- Save the settings and send a test email
Maintenance and Backups
Backing Up Rocket.Chat
Regularly back up your Rocket.Chat instance:
- MongoDB data (the most critical component)
- Uploaded files
- Custom configurations
Here’s a simple backup script you can adapt:
#!/bin/bash
BACKUP_DIR="/path/to/backup/dir/$(date +%Y%m%d)"
mkdir -p $BACKUP_DIR
# Back up MongoDB
docker exec rocketchat_mongodb_1 mongodump --archive --gzip > $BACKUP_DIR/mongodb.archive.gz
# Back up uploads
docker cp rocketchat_rocketchat_1:/app/uploads $BACKUP_DIR/uploads
# Back up compose files
cp ~/rocketchat/.env $BACKUP_DIR/
cp ~/rocketchat/docker-compose.yml $BACKUP_DIR/
Updating Rocket.Chat
To update to a newer version:
- Update the image tag in your
.envfile to the desired version - Run the following commands:
cd ~/rocketchat
docker compose pull
docker compose down
docker compose up -d
Troubleshooting
Common Issues and Solutions
- MongoDB Connection Errors
- Rocket.Chat Can’t Start
- SSL Certificate Issues
- High Resource Usage
Thoughts
You’ve now successfully deployed Rocket.Chat using Docker and Docker Compose with a proper reverse proxy setup for HTTPS. This setup provides:
- A secure communication platform with SSL encryption
- Automatic certificate management with Let’s Encrypt
- Efficient containerization with Docker
- Proper database setup with MongoDB
- Easy maintenance and updates
For more advanced configurations and optimizations, refer to the official Rocket.Chat documentation.
