Mongo docker containter does not start: '/data/db': Permission denied

Description

I would like to let run Rocket.Chat with Docker containers. So I installed it like described at https://rocket.chat/docs/installation/docker-containers/index.html#3-installing-docker-and-docker-compose

But the MongoDB container does not start because of a permission issue. Any idea?

The compose file for MongoDB:

mongo:
    image: mongo
    container_name: "mongo"
    restart: unless-stopped
    volumes:
     - ./data/db:/data/db
     - ./data/dump:/dump
    command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1
  mongo-init-replica:
    image: mongo
    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

Server Setup Information

  • Operating System: CentOS 7.4

Any additional Information

~# docker-compose ps
             Name                            Command                 State              Ports
------------------------------------------------------------------------------------------------------
mongo                             docker-entrypoint.sh mongo ...   Restarting
rocketchat                        bash -c for i in `seq 1 30 ...   Up           0.0.0.0:3000->3000/tcp
rocketchat_mongo-init-replica_1   docker-entrypoint.sh bash  ...   Exit 1


~#  docker-compose logs mongo
Attaching to mongo
mongo                 | find: '/data/db': Permission denied

Hi,

I am having a similar issue here. How did you solve this problem? I’ve attempted this,

sudo chown -R mongodb:mongodb /data/db

followed by a mongodb restart but no luck