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.