Docker Upgrade Issues

Hey folks,

I am having a hell of a time upgrading my one standalone docker container. So far (up to 4.8.1) I have been using this gem:

version: '2'

services:
  rocketchat-nnx:
    image: registry.rocket.chat/rocketchat/rocket.chat:4.8.1
    command: >
      bash -c
        "for i in `seq 1 30`; do
          node main.js &&
          s=$$? && break || s=$$?;
          echo \"Tried $$i times. Waiting 5 secs...\";
          sleep 5;
        done; (exit $$s)"
    restart: unless-stopped
    volumes:
      - /var/docker_data/chat.example.com/rocketchat:/var/lib/rocket.chat
    environment:
      - PORT=3003
      - ROOT_URL=https://chat.example.com
      - MONGO_URL=mongodb://mongo-nnx:27017/rocketchat
      - MONGO_OPLOG_URL=mongodb://mongo-nnx:27017/local
      - MAIL_URL=smtp:/mail.example.com
    depends_on:
      - mongo-nnx
    ports:
      - 3003:3003

  mongo-nnx:
    image: mongo:5.0.6
    restart: unless-stopped
    volumes:
     - /var/docker_data/chat.example.com/db:/data/db
    command: mongod --oplogSize 128 --replSet rs0

Now with RocketChat 5.x, the compose script got rewamped quite a lot. I tried to adapt it to the best of my abilites:

volumes:
  mongo-nnx_data: { driver: local }

services:
  rocketchat-nnx:
    image: registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-latest}
    restart: on-failure
    environment:
      PORT: 3003
      ROOT_URL: https://chat.example.com
      MONGO_URL: mongodb://mongo-nnx:27017/rocketchat
      MONGO_OPLOG_URL: mongodb://mongo-nnx:27017/local
      MAIL_URL: smtp://mail.example.com
      DEPLOY_METHOD: docker
      # DEPLOY_PLATFORM: ${DEPLOY_PLATFORM}
    depends_on:
      - mongo-nnx
    expose:
      - ${PORT:-3000}
    ports:
      - "${BIND_IP:-0.0.0.0}:${HOST_PORT:-3000}:${PORT:-3000}"
    volumes:
      - /var/docker_data/chat.example.com/rocketchat:/var/lib/rocket.chat

  mongo-nnx:
    image: mongo:${MONGODB_VERSION:-4.4}
    restart: on-failure
    volumes:
      - /var/docker_data/chat.example.com/db:/data/db
    environment:
      MONGODB_REPLICA_SET_MODE: primary
      MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0}
      MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017}
      MONGODB_INITIAL_PRIMARY_HOST: ${MONGODB_INITIAL_PRIMARY_HOST:-mongo-nnx}
      MONGODB_INITIAL_PRIMARY_PORT_NUMBER: ${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
      MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongo-nnx}
      MONGODB_ENABLE_JOURNAL: ${MONGODB_ENABLE_JOURNAL:-true}
      ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}
    command: mongod --oplogSize 128 --replSet rs0

With this accomodating .env file:


# Rocket.Chat version
# see:- https://github.com/RocketChat/Rocket.Chat/releases
RELEASE=5.0.5
# MongoDB endpoint (include ?replicaSet= parameter)
MONGO_URL= "mongodb://mongo-nnx:27017/rocketchat?replicaSet=rs0"
# MongoDB endpoint to the local database
MONGO_OPLOG_URL= "mongodb://mongo-nnx:27017/local"
# IP to bind the process to
BIND_IP= "127.0.0.1"
# URL used to access your Rocket.Chat instance
ROOT_URL= "https://chat.example.com"
# Port Rocket.Chat runs on (in-container)
PORT= "3000"
# Port on the host to bind to
HOST_PORT= "3003"
DOMAIN="chat.example.com"

### MongoDB configuration
# MongoDB version/image tag
MONGODB_RELEASE="5.0.6"
MONGODB_VERSION="5.0.6"

Now, mongo boots up and finds its database, but RC fails to connect:

rocketchat-wme-rocketchat-wme-1  |     at Timeout._onTimeout (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/sdam/topology.js:312:38)
rocketchat-wme-rocketchat-wme-1  |     at listOnTimeout (internal/timers.js:557:17)
rocketchat-wme-rocketchat-wme-1  |     at processTimers (internal/timers.js:500:7) {
rocketchat-wme-rocketchat-wme-1  |   reason: TopologyDescription {
rocketchat-wme-rocketchat-wme-1  |     type: 'ReplicaSetNoPrimary',
rocketchat-wme-rocketchat-wme-1  |     servers: Map(1) {
rocketchat-wme-rocketchat-wme-1  |       'localhost:27017' => ServerDescription {
rocketchat-wme-rocketchat-wme-1  |         _hostAddress: HostAddress { isIPv6: false, host: 'localhost', port: 27017 },
rocketchat-wme-rocketchat-wme-1  |         address: 'localhost:27017',
rocketchat-wme-rocketchat-wme-1  |         type: 'Unknown',
rocketchat-wme-rocketchat-wme-1  |         hosts: [],
rocketchat-wme-rocketchat-wme-1  |         passives: [],
rocketchat-wme-rocketchat-wme-1  |         arbiters: [],
rocketchat-wme-rocketchat-wme-1  |         tags: {},
rocketchat-wme-rocketchat-wme-1  |         minWireVersion: 0,
rocketchat-wme-rocketchat-wme-1  |         maxWireVersion: 0,
rocketchat-wme-rocketchat-wme-1  |         roundTripTime: -1,
rocketchat-wme-rocketchat-wme-1  |         lastUpdateTime: 448106514,
rocketchat-wme-rocketchat-wme-1  |         lastWriteDate: 0,
rocketchat-wme-rocketchat-wme-1  |         error: MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
rocketchat-wme-rocketchat-wme-1  |             at connectionFailureError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:381:20)
rocketchat-wme-rocketchat-wme-1  |             at Socket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connect.js:301:22)
rocketchat-wme-rocketchat-wme-1  |             at Object.onceWrapper (events.js:520:26)
rocketchat-wme-rocketchat-wme-1  |             at Socket.emit (events.js:400:28)
rocketchat-wme-rocketchat-wme-1  |             at emitErrorNT (internal/streams/destroy.js:106:8)
rocketchat-wme-rocketchat-wme-1  |             at emitErrorCloseNT (internal/streams/destroy.js:74:3)
rocketchat-wme-rocketchat-wme-1  |             at processTicksAndRejections (internal/process/task_queues.js:82:21)
rocketchat-wme-rocketchat-wme-1  |       }
rocketchat-wme-rocketchat-wme-1  |     },
rocketchat-wme-rocketchat-wme-1  |     stale: false,
rocketchat-wme-rocketchat-wme-1  |     compatible: true,
rocketchat-wme-rocketchat-wme-1  |     heartbeatFrequencyMS: 10000,
rocketchat-wme-rocketchat-wme-1  |     localThresholdMS: 15,
rocketchat-wme-rocketchat-wme-1  |     setName: 'rs0',
rocketchat-wme-rocketchat-wme-1  |     maxSetVersion: 1,
rocketchat-wme-rocketchat-wme-1  |     maxElectionId: ObjectId {
rocketchat-wme-rocketchat-wme-1  |       [Symbol(id)]: Buffer(12) [Uint8Array] [
rocketchat-wme-rocketchat-wme-1  |         127, 255, 255, 255, 0,
rocketchat-wme-rocketchat-wme-1  |           0,   0,   0,   0, 0,
rocketchat-wme-rocketchat-wme-1  |           0,  16
rocketchat-wme-rocketchat-wme-1  |       ]
rocketchat-wme-rocketchat-wme-1  |     },
rocketchat-wme-rocketchat-wme-1  |     commonWireVersion: 13,
rocketchat-wme-rocketchat-wme-1  |     logicalSessionTimeoutMinutes: undefined
rocketchat-wme-rocketchat-wme-1  |   }
rocketchat-wme-rocketchat-wme-1  | }
rocketchat-wme-rocketchat-wme-1 exited with code 1

It tries to connect to 127.0.0.1? Why would it do that?
I set all the urls correctly; or is it due to the repl issue?

I would use the new compose, but I do not know how to migrate from old to the new. The upgrade path is not clear (or documented).

Help please :slight_smile:

Hi!

We did a Rocket.Lab about this a couple weeks ago:

TLDR: with the change of the node connector for mongo, you need to change some some parameters for configuring it properly.

If you read thru the release notes of the 5.0.0 version, you will see an important note:

If you’re using MongoDB in a Docker container, you might need to add directConnection=true to MONGO_URL and MONGO_OPLOG_URL environment variables. i.e.: MONGO_URL=mongodb://mongo/rocketchat?replicaSet=rs0&directConnection=true

Let me know if this helps.

Can you be more specific, please?
I am not IT Pro so I would like to know how to change my docker-compose.yml

Running in docker Rocketchat 4.8.1 + MongoDB 4.4.16
I have these lines inside my file.

environment:
      - PORT=3000 
      - ROOT_URL=http://localhost:3000
      - MONGO_URL=mongodb://mongo:27017/rocketchat 
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local
      - MAIL_URL=smtp://smtp.email

Can you please show me the correct code for both lines MONGO_URL and MONGO_OPLOG_URL
Thank you very much for your reply.

Hi!

This is about it:

environment:
      - PORT=3000 
      - ROOT_URL=http://localhost:3000
      - MONGO_URL=mongodb://mongo:27017/rocketchat?directConnection=true 
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local?directConnection=true
      - MAIL_URL=smtp://smtp.email

Also, you can use this compose.yml as a reference:

On this case, the env var MONGODB_ADVERTISED_HOSTNAME is the one providing the necessary configs to avoid this connection error.

Thank you for your reply.
I edited docker-compose.yml as you mentioned above

      - MONGO_URL=mongodb://mongo:27017/rocketchat?directConnection=true 
      - MONGO_OPLOG_URL=mongodb://mongo:27017/local?directConnection=true

RocketChat 5.0.5 started in the latest version but there is another problem.
When I switch to any Room I see the error message:
Something went wrong. Please reload the page or contact an administrator.

How to fix please?
docker Rocketchat 5.0.5 + MongoDB 4.4.16
I had to restore from backup back to RC 4.8.1 + MongoDB 4.4.16

PS: I must use MongoDB 4.4 because my CPU is not supported by MongoDB 5.

Thank you for your answer.

Mongo 4.4 should be fine. Indeed Mongo 5 has some compatibility issues with some CPUs

Do you see any outstanding log in developer console?
Have you tried a hard refresh on the browser? Sometimes this can be cause by cache.

THanks!

That solved the issue completly. Thank you very much!
(Sorry for the delayed answer).

2 Likes

Just for info - Rocketchat 5.1.1 + MongoDB 4.4.16 - I can confirm that it seems to work fine.

I only added

Thank you.

1 Like