简体   繁体   中英

How to enable access control for MongoDB with Docker (Plesk)

How do I enable access control for my MongoDB server? This line shows up in the log:

CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.

I use Plesk to start MongoDB and I have read their manual about it but it doesn't tell me how to enable access control since I can only add environment variables and volume mapping via the Plesk control panel such as /data/db and /data/configdb.

I'm able to use a terminal to login without credentials to create a superadmin and all the roles, but that doesn't solve the unrestricted access.

I can also access files within the container with this:

docker exec -it mongo /bin/bash

And I see this directory: docker-entrypoint-initdb.d but I don't know what to put there. Also packages that I installed inside the container like vim don't persist and are lost after a restart.

Furthermore I have no idea where Plesk is storing the docker-compose.yml file. Is this a file that only belongs inside a image file?

If I change the /etc/mongod.conf and add this:

security: authorization: enabled

nothing happens after restart, could I get some help with this?

system information:

  • Plesk Onyx 17.8.11 Update 25
  • Host: CentOS 7.5.1804
  • Container: Ubuntu 16.04
  • Docker version 18.06.1-ce, build e68fc7a

You should read the library/mongo image documentation : https://hub.docker.com/_/mongo/

If you want to use your own mongo configuration file, put it somewhere like /etc/mongo/mongod.conf in your container (with volume or COPY). After that you have to tell to mongo to use it as configuration file :

$ docker run --config /etc/mongo/mongod.conf

Or in docker-compose :

services:
    mongo:
        image: mongo
        command: --config /etc/mongo/mongod.conf

I can't help you for the location of Plesk docker-compose.yml, try to use find command.

I hope it will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM