mongo icon indicating copy to clipboard operation
mongo copied to clipboard

docker mongodb replica keyfile Permission denied

Open Jaware opened this issue 11 years ago • 5 comments

i use keyfile as docker mongodb replica security tool, however when run with -v /data/mongo/keyfile:/data/keyfile,it showed keyfile Permission denied ,the keyfile is 600(mongo need)

Jaware avatar Jan 05 '15 12:01 Jaware

The permission mask should be fine, but the file will need to be owned by the mongodb user in the container (uid=999(mongodb) gid=999(mongodb)).

yosifkit avatar Jan 05 '15 16:01 yosifkit

sorry ,i do not know how to do that,can you explain a little more clear

Jaware avatar Jan 06 '15 14:01 Jaware

You'll just need to chown 999:999 keyfile before you run the docker container (you probably need sudo in there).

yosifkit avatar Jan 06 '15 18:01 yosifkit

thanks,sorry too busy these days

Jaware avatar Feb 07 '15 02:02 Jaware

@yosifkit how can I do that from my docker-compose.yml file?

  db:
    image: mongo:4.4.3
    hostname: mongo-db-001
    command: --replSet bg0 --keyFile /etc/mongodb.key
    volumes:
      - ./mongodb.key:/etc/mongodb.key
    ports:
      - "27017:27017"
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: 'foo'
      MONGO_INITDB_ROOT_PASSWORD: 'bar'
      MONGO_INITDB_DATABASE: baz

oxr463 avatar Jan 06 '21 14:01 oxr463