Migrating from native install to docker

Description

Hey folks! I have been running (and am) a standalone installation of rocketchat for years now, using the release ball from the website and mongo 5.0.5. This works like a charm.

Now I want to move inside docker. For this I created a native mongo container:

docker run --name rc-mongo --restart unless-stopped -v /var/docker_data/chat.alpha-labs.net/mongo:/data/db -p 27017:27017 -d mongo:5.0.5 --replSet rs01

Before running I populated the mongo directory with the current data dir (of the same version) from the standalone. Running it worked; logs okay. I entered the container and verified with mongosh that rs01 is a valid replica set and that the (only) mongo server is primary. Check.

I then continued running rocketchat with

docker run --name rc-system --restart unless-stopped -d -p 8085:3000 --env ROOT_URL=https://chat.alpha-labs.net --env MONGO_URL="mongodb://kaitaan.alpha-labs.net:27017/rocketchat?replicaSet=rs01" -v /var/docker_data/chat.alpha-labs.net/uploads:/uploads rocket.chat

This fails with…

MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
    at Timeout._onTimeout (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/sdam/topology.js:437:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: 'rs01',
    maxSetVersion: 1,
    maxElectionId: ObjectID {
      _bsontype: 'ObjectID',
      id: Buffer(12) [Uint8Array] [
        127, 255, 255, 255, 0,
          0,   0,   0,   0, 0,
          0,  16
      ]
    },
    servers: Map {
      '127.0.0.1:27017' => ServerDescription {
        address: '127.0.0.1:27017',
        error: Error: connect ECONNREFUSED 127.0.0.1:27017
            at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 74333876,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: 13
  }
}

Please note the mongo server of 127.0.0.1, which is not correct. Mongo URL clearly states fqdn.
Here is the funky part: The rocketchat container did talk to the mongo container (connection ok). When I stop the mongo container and rerun the rocketchat container, not changing anything:

MongoServerSelectionError: connect ECONNREFUSED 84.246.124.51:27017
    at Timeout._onTimeout (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/sdam/topology.js:437:30)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map {
      'kaitaan.alpha-labs.net:27017' => ServerDescription {
        address: 'kaitaan.alpha-labs.net:27017',
        error: Error: connect ECONNREFUSED 84.246.124.51:27017
            at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 74664221,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        topologyVersion: undefined,
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: null
  }
}

Please note the correct ip from the environment. Seems the mongo url is stored inside mongo?

This is also reproducable via the official docker container, at least the above error. Emptying the mongo directory and running above commands results in a working state container, asking me to authenticate/register the installation.

I am at a loss. How would I change the Mongo Url inside the Mongo db? Whats going on here?

-Chris.

I am not running the docker but I am looking to transferring to it in the future.

From what I can read, you would edit it in the docker-yaml file as that is where the Mongo URL (aka Rocketchat_URL) I will link where I found this information:

RocketChat Docs (Step Six)

Hopefully this helps.

Hey,

thanks for replying; but sorry no. Thats only the instructions on how to move. I have an issue inside mongodb it seems.

Hi!

Consider using our oficial docker-compose instead of isolated docker containers.

Once you are up and running with the same version you run now, you restore the mongo data into this database. From there, you can upgrade just by pulling and spinning and new container referencing the latest version.

Ah. That was the solution.

Your docker-compose (curl -L https://go.rocket.chat/i/docker-compose.yml -O) yielded in a different file that the one I got from https://github.com/RocketChat/Docker.Official.Image.

With yours I was able to fiddle everything in place, back online! Thanks!

1 Like

As you are migrating, bear in mind that our oficial docker-compose is still using mongo 4.0 with mmap storage engine.

One thing you could do now that will save you from migrating this later, is to use wiredtiger instead.

Here we have a thread that have information on how to do that (small changes)

Here you have supported mongo versions, note that mongo 4.0 is deprecated in Rocket.Chat 4.X, and will probably not be supported later in Rocket.Chat 5.X

Thanks for the heads-up!

But luckily I directly migrated to 5.x of mongo using 4.0.2 rocketchat. Works like a charm :slight_smile:

1 Like