# Migrating from native install to docker

**URL:** https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123
**Category:** Community Support
**Created:** [January 28, 2022, 9:48am UTC](https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123 "2022-01-28T09:48:42Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![creiss](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/creiss/32/3455_2.png) [@creiss](https://forums.rocket.chat/u/creiss)
#### Post date: [January 28, 2022, 9:48am UTC](https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123/1 "2022-01-28T09:48:42Z")

</div>

### 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…

```auto
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:

```auto
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.

---

<div class="post-metadata">

### Author: ![moesestt](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@moesestt](https://forums.rocket.chat/u/moesestt)
#### Post date: [January 28, 2022, 4:56pm UTC](https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123/2 "2022-01-28T16:56:49Z")

</div>

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)](https://docs.rocket.chat/quick-start/installing-and-updating/docker-containers)

Hopefully this helps.

---

<div class="post-metadata">

### Author: ![creiss](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/creiss/32/3455_2.png) [@creiss](https://forums.rocket.chat/u/creiss)
#### Post date: [January 31, 2022, 3:35pm UTC](https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123/3 "2022-01-31T15:35:38Z")

</div>

Hey,

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

---

<div class="post-metadata">

### Author: ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)
#### Post date: [February 1, 2022, 7:33pm UTC](https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123/4 "2022-02-01T19:33:43Z")

</div>

Hi!

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

> **[Docker Compose](https://docs.rocket.chat/quick-start/installing-and-updating/docker-containers/docker-compose)**

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.

---

<div class="post-metadata">

### Author: ![creiss](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/creiss/32/3455_2.png) [@creiss](https://forums.rocket.chat/u/creiss)
#### Post date: [February 3, 2022, 1:05pm UTC](https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123/5 "2022-02-03T13:05:31Z")

</div>

Ah. That was the solution.

Your docker-compose (curl -L [https://go.rocket.chat/i/docker-compose.yml](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](https://github.com/RocketChat/Docker.Official.Image).

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

---

<div class="post-metadata">

### Author: ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)
#### Post date: [February 3, 2022, 1:12pm UTC](https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123/6 "2022-02-03T13:12:16Z")

</div>

**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)

> [@wiredTiger migration hasn't started yet. Waiting 30 secs](https://forums.rocket.chat/t/wiredtiger-migration-hasnt-started-yet-waiting-30-secs/13053/4):
>
> This docker was supposed to be changed already. indeed. grimacing For using with wiredtiger, on a new installation, you need only to change the mongo services, like so: mongo: image: mongo:4.4 restart: unless-stopped volumes: - ./data/rocketchat\_db:/data/db - ./data/rocketchat\_dump/dump:/dump command: mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger labels: - "traefik.enable=false" # this container's job is just run the command to initi…

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

> **[Rocket.Chat's Support Structure](https://docs.rocket.chat/resources/rocket.chats-support-structure)**

---

<div class="post-metadata">

### Author: ![creiss](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/creiss/32/3455_2.png) [@creiss](https://forums.rocket.chat/u/creiss)
#### Post date: [February 3, 2022, 1:32pm UTC](https://forums.rocket.chat/t/migrating-from-native-install-to-docker/13123/7 "2022-02-03T13:32:47Z")

</div>

Thanks for the heads-up!

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