Deploy RocketChat and MongoDB on different Hosts [Docker]


Hello guys,
I am trying to deploy RocketChat and MongoDB on different Hosts with Docker.
RocketChat on Host
MongoDB on Host

I am using the commands specified in here:

$ docker run --name db -d mongo:4.0 --smallfiles --replSet rs0 --oplogSize 128

$ docker exec -ti db mongo --eval “printjson(rs.initiate())”

Now im struggling with this part:

If you’re using a third party Mongo provider, or working with Kubernetes, you need to override the MONGO_URL environment variable:

$ docker run --name rocketchat -p 80:3000 --env ROOT_URL=http://localhost --env MONGO_URL=mongodb://mymongourl/mydb --env MONGO_OPLOG_URL=mongodb://mymongourl:27017/local -d

I followed this topic, which is similar with a different deployment method: How configure Rocket Chat and MongoDB in separatelly hosts?
So first I tried to deploy RC by using following parameters:

and also

Both versions gives me an error.

I also tried changing the mongod.conf within the container to:
port: 27017
bindIp: ##normally its

How can I define a specific container for these parameters?

I would be very thankful for any help.

Server Setup Information

  • Version of Rocket.Chat Server:
  • Operating System: Ubuntu 18.04
  • Deployment Method: Docker
  • Number of Running Instances: one on each host
  • DB Replicaset Oplog: enabled
  • NodeJS Version: 12.16.1 - x64
  • MongoDB Version: 4.0.20
  • Proxy: nginx
  • Firewalls involved: none

You need to expose the mongodb Port.

So in your case: docker run --name db -d mongo:4.0 --smallfiles --replSet rs0 --oplogSize 128 -p

After that, you can access mongodb on port 27017 via IP

thank you for your reply.

I have found a different solution to solve the problem. I created a new Docker network with the same IP range that the hosts have. Then I assigned an IP address to the container, which allowed me to access them like this:

But your solution is much more simple and works too.