# Rocket.Chat Team Platform

> Rocket.Chat team communication with MongoDB.

- Category: Message Queues & Brokers
- Difficulty: intermediate
- Components: rocketchat, mongodb
- Tags: rocketchat, chat, team, communication, mongodb
- Source: https://docker.recipes/messaging/rocketchat-team

## Overview

Rocket.Chat is an open-source team communication platform that provides organizations with complete control over their messaging infrastructure. Originally launched in 2015 as a self-hosted alternative to Slack and Microsoft Teams, Rocket.Chat offers real-time messaging, video conferencing, file sharing, and extensive customization options without vendor lock-in or data privacy concerns inherent in cloud-based solutions. The platform supports unlimited users, channels, and integrations while maintaining enterprise-grade security features like end-to-end encryption and compliance certifications. This deployment combines Rocket.Chat with MongoDB configured as a replica set, which is essential for Rocket.Chat's real-time features and data consistency. MongoDB's oplog (operations log) enables Rocket.Chat to track database changes in real-time, powering live message updates, presence indicators, and notification systems across all connected clients. The replica set configuration, even with a single node, provides the oplog functionality that Rocket.Chat requires for optimal performance. Organizations seeking complete control over their communication data will find this stack particularly valuable. Unlike hosted solutions, this deployment keeps all messages, files, and user data within your infrastructure, making it ideal for companies with strict data governance requirements, government agencies, healthcare organizations, or any team that prioritizes data sovereignty and customization flexibility over convenience.

## Features

- Real-time messaging with MongoDB oplog integration for instant message delivery across all clients
- Built-in video conferencing and screen sharing capabilities without external dependencies
- Federation support allowing communication with other Rocket.Chat instances and Matrix protocol servers
- Extensive marketplace with hundreds of apps and integrations including Jira, GitHub, and Zapier
- Omnichannel customer service features with live chat widgets, WhatsApp, and SMS integration
- Advanced user management with LDAP/Active Directory sync and custom roles and permissions
- End-to-end encryption for private conversations and sensitive communications
- Thread-based discussions and message reactions for organized team collaboration

## Use cases

- Remote-first companies needing complete control over communication data and compliance
- Healthcare organizations requiring HIPAA-compliant team communication and patient consultation
- Government agencies and defense contractors with strict data sovereignty requirements
- Educational institutions managing student-teacher communication and virtual classrooms
- Software development teams integrating with GitHub, GitLab, and CI/CD pipelines
- Customer support organizations using omnichannel features for unified communication
- International organizations leveraging federation to connect distributed Rocket.Chat instances

## Prerequisites

- Minimum 4GB RAM recommended (2GB for Rocket.Chat, 2GB for MongoDB with oplog operations)
- Docker and Docker Compose installed with sufficient storage for MongoDB data growth
- Port 3000 available for Rocket.Chat web interface access
- Understanding of MongoDB replica sets and oplog concepts for troubleshooting
- Valid domain name and SSL certificates for production deployments with federation
- Network configuration allowing MongoDB replica set initialization and internal communication

## docker-compose.yml

```yaml
services:
  mongodb:
    image: mongo:6
    container_name: rocketchat-mongo
    restart: unless-stopped
    command: mongod --oplogSize 128 --replSet rs0
    volumes:
      - mongo_data:/data/db
    networks:
      - rocketchat-network

  mongo-init-replica:
    image: mongo:6
    container_name: mongo-init-replica
    command: >
      bash -c "sleep 10 && mongosh mongodb/rocketchat --eval 'rs.initiate({_id: "rs0", members: [{_id: 0, host: "mongodb:27017"}]})'"
    depends_on:
      - mongodb
    networks:
      - rocketchat-network

  rocketchat:
    image: rocket.chat:latest
    container_name: rocketchat
    restart: unless-stopped
    ports:
      - "${ROCKETCHAT_PORT:-3000}:3000"
    environment:
      - ROOT_URL=${ROOT_URL:-http://localhost:3000}
      - MONGO_URL=mongodb://mongodb:27017/rocketchat?replicaSet=rs0
      - MONGO_OPLOG_URL=mongodb://mongodb:27017/local?replicaSet=rs0
      - DEPLOY_METHOD=docker
    depends_on:
      - mongodb
    networks:
      - rocketchat-network

volumes:
  mongo_data:

networks:
  rocketchat-network:
    driver: bridge
```

## .env

```bash
# Rocket.Chat
ROCKETCHAT_PORT=3000
ROOT_URL=http://localhost:3000
```

## Usage notes

- Rocket.Chat at http://localhost:3000
- Setup wizard on first run
- Supports federation
- Many integrations available

## Troubleshooting

- Rocket.Chat shows 'Cannot connect to database' error: Ensure MongoDB replica set is initialized by checking mongo-init-replica container logs and verifying rs.status() in MongoDB shell
- Real-time features not working (messages don't appear instantly): Verify MONGO_OPLOG_URL is correctly configured and MongoDB oplog is functioning with rs.printReplicationInfo()
- Rocket.Chat container fails to start with SIGKILL: Increase Docker memory limits as Rocket.Chat requires significant RAM during initialization, especially with MongoDB operations
- Federation or webhooks not working: Check ROOT_URL environment variable matches your actual domain and is accessible from external services
- MongoDB replica set fails to initialize: Ensure mongodb container is fully started before mongo-init-replica runs, increase sleep time if necessary
- File uploads failing or timing out: Verify sufficient disk space in mongo_data volume and adjust MongoDB's GridFS settings for large file handling

