Install RocketChat with Docker Compose for Development

If you ask me: what the hell Rocketchat is, then you should better ask Google. This article notes steps to install RocketChat with Docker Compose for development purpose.

1. Create docker-compose.yml

I want to expose the mongo port (27017) to the host network so I also declare it in the ports param. I also map the default rocketchat port (3000) to port 4000 in the host since I am using port 3000 for another service.

version: "3"
    image: mongo
      - 27017:27017
      - ./data/runtime/db:/data/db
      - ./data/dump:/dump
    command: mongod --smallfiles --oplogSize 128
      - rcnet
    image: rocketchat/
      - MONGO_URL=mongodb://mongo/rocketchat
      - ROOT_URL=http://chat.localhost
      - PORT=3000
      - rcnet
      - 4000:3000
      - mongo
    driver: bridge


2. Start services

It is worth noting that you need to start mongo and rocketchat sequentially. If you simply run docker-compose up, the rocketchat service cannot recognize mongo service is completely started, so it fails since there is no retry after that. Even if you put the depends info in the docker-compose.yml, it still fails. The following error will appear:

MongoError: failed to connect to server [mongo:27017] on first connect [MongoError: connect ECONNREFUSED]

So, you should start mongo service first, and then start the rocketchat service as follows:

docker-compose up -d mongo
docker-compose up -d rocketchat



About NhocConan

A super lazy guy who tries to write tech blog entries in English.He is lazy, so he can only write when he is in a good mood or when he is tired of coding.

Leave a comment

Your email address will not be published. Required fields are marked *