Rocketchat failed to run via docker-compose

Description

Using rocket.chat image here’s the docker-compose.yml

        rocketchat:
                image: rocket.chat
                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:
                        - ./uploads:/app/uploads
                environment:
                        - PORT=7000
                        - ROOT_URL=http://mywebsite.com:8065
                        - MONGO_URL=mongodb://mongo:27017/rocketchat
                        - MONGO_OPLOG_URL=mongodb://mongo:27017/local
                        - MAIL_URL=smtp://smtp.email
                depends_on:
                        - mongo
                ports:
                        - 7000:7000
                labels:
                        - "traefik.backend=rocketchat"
                        - "traefik.frontend.rule=Host: your.domain.tld"
        mongo:
                image: mongo:4.0
                restart: unless-stopped
                volumes:
                        - ./data/db:/data/db
                command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1
                labels:
                        - "traefik.enable=false"
        mongo-init-replica:
                image: mongo:4.0
                command: >
                        bash -c
                                "for i in `seq 1 30`; do
                                        mongo mongo/rocketchat --eval \"
                                                rs.initiate({
                                                _id: 'rs0',
                                members: [ { _id: 0, host: 'localhost:27017' } ]})\" &&
                                s=$$? && break || s=$$?;
                                echo \"Tried $$i times. Waiting 5 secs...\";
                                sleep 5;
                        done; (exit $$s)"
                depends_on:
                        - mongo

Docker logs for rocketchat container:

MongoError: not master and slaveOk=false
    at Connection.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:451:61)
    at Connection.emit (events.js:315:20)
    at processMessage (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:452:10)
    at Socket.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:621:15)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
  operationTime: Timestamp { _bsontype: 'Timestamp', low_: 0, high_: 0 },
  ok: 0,
  code: 13435,
  codeName: 'NotMasterNoSlaveOk',
  '$clusterTime': {
    clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 0, high_: 0 },
    signature: {
      hash: Binary {
        _bsontype: 'Binary',
        sub_type: 0,
        position: 20,
        buffer: Buffer(20) [Uint8Array] [
          0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0, 0,
          0, 0, 0, 0, 0, 0
        ]
      },
      keyId: 0
    }
  }
}
Tried 4 times. Waiting 5 secs...

yes ! I am facing the same issue. Did you solve it?

Hard to tell if you have the same issue as you haven’t posted any logs or config.

On this particular issue the ports and URLs are all wrong hence the error.