docker.recipes

Rocket.Chat + MongoDB + Hubot

intermediate

Open source team chat with chatbot integration.

Overview

Rocket.Chat is an open-source team communication platform that provides Slack-like messaging, video conferencing, file sharing, and extensive collaboration features. Originally developed in 2015 as a customizable alternative to proprietary team chat solutions, Rocket.Chat offers organizations complete control over their communication data and infrastructure while supporting thousands of concurrent users with real-time messaging, channels, direct messages, and integrations with over 300 third-party services. This deployment combines Rocket.Chat with MongoDB's document database for flexible message and user data storage, while Hubot provides intelligent chatbot automation for common tasks like deployments, monitoring alerts, and team workflows. MongoDB's replica set configuration ensures high availability for chat history and user data, while NGINX handles SSL termination, static file serving, and load balancing to optimize performance under heavy concurrent user loads. This stack is ideal for organizations requiring self-hosted team communication with advanced bot automation, companies needing GDPR compliance or data sovereignty, development teams wanting ChatOps integration for CI/CD workflows, and enterprises seeking cost-effective alternatives to Slack or Microsoft Teams with complete customization control.

Key Features

  • Real-time messaging with MongoDB change streams for instant message delivery and presence updates
  • Hubot ChatOps integration with customizable scripts for automated deployments, monitoring, and team workflows
  • MongoDB replica set configuration providing automatic failover and data redundancy for chat history
  • NGINX reverse proxy with WebSocket support for optimized real-time communication performance
  • Rocket.Chat's extensive plugin ecosystem with over 300 integrations including GitHub, Jira, and CI/CD tools
  • Multi-channel architecture supporting unlimited public channels, private groups, and direct messaging
  • Built-in video conferencing with Jitsi Meet integration and screen sharing capabilities
  • Advanced user management with LDAP/Active Directory integration and custom authentication providers

Common Use Cases

  • 1DevOps teams implementing ChatOps workflows with Hubot automation for deployment notifications and server monitoring alerts
  • 2Remote-first companies requiring self-hosted team communication with complete data ownership and GDPR compliance
  • 3Software development teams needing integrated chat with GitHub webhooks, CI/CD notifications, and code review discussions
  • 4Healthcare or financial organizations requiring HIPAA or SOX compliant team communication with on-premises data storage
  • 5Educational institutions providing students and faculty with collaborative workspaces and course-specific communication channels
  • 6Customer support teams using Rocket.Chat's omnichannel features with automated bot responses for common inquiries
  • 7International organizations needing multilingual team communication with custom translation bots and region-specific channels

Prerequisites

  • Docker Engine 20.10+ and Docker Compose v2 for container orchestration and networking support
  • Minimum 4GB RAM (8GB recommended) to handle MongoDB replica set, Rocket.Chat application, and concurrent user sessions
  • Available ports 80, 3000, and 27017 for NGINX, Rocket.Chat, and MongoDB inter-service communication
  • SSL certificate and domain name for production deployment with proper WebSocket and real-time messaging support
  • Basic understanding of MongoDB replica sets and Rocket.Chat administration for user management and bot configuration
  • Environment variables configured for admin credentials, bot authentication, and database connection strings

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 rocketchat:
3 image: rocket.chat:latest
4 environment:
5 - ROOT_URL=http://localhost
6 - MONGO_URL=mongodb://mongodb:27017/rocketchat
7 - MONGO_OPLOG_URL=mongodb://mongodb:27017/local
8 - PORT=3000
9 - ADMIN_USERNAME=${ADMIN_USERNAME}
10 - ADMIN_PASS=${ADMIN_PASS}
11 - ADMIN_EMAIL=${ADMIN_EMAIL}
12 volumes:
13 - rocketchat-uploads:/app/uploads
14 ports:
15 - "3000:3000"
16 depends_on:
17 - mongodb
18 networks:
19 - rocketchat-network
20 restart: unless-stopped
21
22 mongodb:
23 image: mongo:6.0
24 command: mongod --oplogSize 128 --replSet rs0
25 volumes:
26 - mongodb-data:/data/db
27 networks:
28 - rocketchat-network
29 restart: unless-stopped
30
31 mongo-init-replica:
32 image: mongo:6.0
33 command: >
34 bash -c "sleep 10 && mongosh mongodb/rocketchat --eval 'rs.initiate()'"
35 depends_on:
36 - mongodb
37 networks:
38 - rocketchat-network
39
40 hubot:
41 image: rocketchat/hubot-rocketchat:latest
42 environment:
43 - ROCKETCHAT_URL=rocketchat:3000
44 - ROCKETCHAT_ROOM=
45 - ROCKETCHAT_USER=${BOT_USER}
46 - ROCKETCHAT_PASSWORD=${BOT_PASSWORD}
47 - BOT_NAME=bot
48 - EXTERNAL_SCRIPTS=hubot-help,hubot-diagnostics
49 depends_on:
50 - rocketchat
51 networks:
52 - rocketchat-network
53 restart: unless-stopped
54
55 nginx:
56 image: nginx:alpine
57 volumes:
58 - ./nginx.conf:/etc/nginx/nginx.conf:ro
59 ports:
60 - "80:80"
61 depends_on:
62 - rocketchat
63 networks:
64 - rocketchat-network
65 restart: unless-stopped
66
67volumes:
68 rocketchat-uploads:
69 mongodb-data:
70
71networks:
72 rocketchat-network:
73 driver: bridge

.env Template

.env
1# Rocket.Chat
2ADMIN_USERNAME=admin
3ADMIN_PASS=secure_admin_password
4ADMIN_EMAIL=admin@example.com
5
6# Hubot
7BOT_USER=hubot
8BOT_PASSWORD=hubot_password

Usage Notes

  1. 1Rocket.Chat at http://localhost:3000
  2. 2Setup wizard on first run
  3. 3Create bot user for Hubot
  4. 4MongoDB replica set required
  5. 5Mobile and desktop apps available

Individual Services(5 services)

Copy individual services to mix and match with your existing compose files.

rocketchat
rocketchat:
  image: rocket.chat:latest
  environment:
    - ROOT_URL=http://localhost
    - MONGO_URL=mongodb://mongodb:27017/rocketchat
    - MONGO_OPLOG_URL=mongodb://mongodb:27017/local
    - PORT=3000
    - ADMIN_USERNAME=${ADMIN_USERNAME}
    - ADMIN_PASS=${ADMIN_PASS}
    - ADMIN_EMAIL=${ADMIN_EMAIL}
  volumes:
    - rocketchat-uploads:/app/uploads
  ports:
    - "3000:3000"
  depends_on:
    - mongodb
  networks:
    - rocketchat-network
  restart: unless-stopped
mongodb
mongodb:
  image: mongo:6.0
  command: mongod --oplogSize 128 --replSet rs0
  volumes:
    - mongodb-data:/data/db
  networks:
    - rocketchat-network
  restart: unless-stopped
mongo-init-replica
mongo-init-replica:
  image: mongo:6.0
  command: |
    bash -c "sleep 10 && mongosh mongodb/rocketchat --eval 'rs.initiate()'"
  depends_on:
    - mongodb
  networks:
    - rocketchat-network
hubot
hubot:
  image: rocketchat/hubot-rocketchat:latest
  environment:
    - ROCKETCHAT_URL=rocketchat:3000
    - ROCKETCHAT_ROOM=
    - ROCKETCHAT_USER=${BOT_USER}
    - ROCKETCHAT_PASSWORD=${BOT_PASSWORD}
    - BOT_NAME=bot
    - EXTERNAL_SCRIPTS=hubot-help,hubot-diagnostics
  depends_on:
    - rocketchat
  networks:
    - rocketchat-network
  restart: unless-stopped
nginx
nginx:
  image: nginx:alpine
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
  ports:
    - "80:80"
  depends_on:
    - rocketchat
  networks:
    - rocketchat-network
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 rocketchat:
5 image: rocket.chat:latest
6 environment:
7 - ROOT_URL=http://localhost
8 - MONGO_URL=mongodb://mongodb:27017/rocketchat
9 - MONGO_OPLOG_URL=mongodb://mongodb:27017/local
10 - PORT=3000
11 - ADMIN_USERNAME=${ADMIN_USERNAME}
12 - ADMIN_PASS=${ADMIN_PASS}
13 - ADMIN_EMAIL=${ADMIN_EMAIL}
14 volumes:
15 - rocketchat-uploads:/app/uploads
16 ports:
17 - "3000:3000"
18 depends_on:
19 - mongodb
20 networks:
21 - rocketchat-network
22 restart: unless-stopped
23
24 mongodb:
25 image: mongo:6.0
26 command: mongod --oplogSize 128 --replSet rs0
27 volumes:
28 - mongodb-data:/data/db
29 networks:
30 - rocketchat-network
31 restart: unless-stopped
32
33 mongo-init-replica:
34 image: mongo:6.0
35 command: >
36 bash -c "sleep 10 && mongosh mongodb/rocketchat --eval 'rs.initiate()'"
37 depends_on:
38 - mongodb
39 networks:
40 - rocketchat-network
41
42 hubot:
43 image: rocketchat/hubot-rocketchat:latest
44 environment:
45 - ROCKETCHAT_URL=rocketchat:3000
46 - ROCKETCHAT_ROOM=
47 - ROCKETCHAT_USER=${BOT_USER}
48 - ROCKETCHAT_PASSWORD=${BOT_PASSWORD}
49 - BOT_NAME=bot
50 - EXTERNAL_SCRIPTS=hubot-help,hubot-diagnostics
51 depends_on:
52 - rocketchat
53 networks:
54 - rocketchat-network
55 restart: unless-stopped
56
57 nginx:
58 image: nginx:alpine
59 volumes:
60 - ./nginx.conf:/etc/nginx/nginx.conf:ro
61 ports:
62 - "80:80"
63 depends_on:
64 - rocketchat
65 networks:
66 - rocketchat-network
67 restart: unless-stopped
68
69volumes:
70 rocketchat-uploads:
71 mongodb-data:
72
73networks:
74 rocketchat-network:
75 driver: bridge
76EOF
77
78# 2. Create the .env file
79cat > .env << 'EOF'
80# Rocket.Chat
81ADMIN_USERNAME=admin
82ADMIN_PASS=secure_admin_password
83ADMIN_EMAIL=admin@example.com
84
85# Hubot
86BOT_USER=hubot
87BOT_PASSWORD=hubot_password
88EOF
89
90# 3. Start the services
91docker compose up -d
92
93# 4. View logs
94docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/rocketchat-complete/run | bash

Troubleshooting

  • Error 'Rocket.Chat can't connect to MongoDB': Ensure MongoDB replica set is initialized by checking mongo-init-replica container logs and waiting for rs.initiate() completion
  • Hubot not responding to commands: Verify BOT_USER exists in Rocket.Chat with 'bot' role and BOT_PASSWORD matches the account credentials exactly
  • MongoDB replica set failing to start: Check available disk space and ensure --oplogSize 128 parameter allows sufficient oplog storage for chat message replication
  • NGINX 502 Bad Gateway errors: Confirm Rocket.Chat container is fully started on port 3000 and MongoDB connection is established before NGINX proxy attempts
  • Real-time messaging delays or failures: Verify WebSocket connections aren't blocked by firewall and NGINX proxy_set_header Upgrade and Connection are properly configured
  • Rocket.Chat admin setup wizard not appearing: Clear browser cache and ensure ROOT_URL environment variable matches the actual domain or IP being accessed

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space