简体   繁体   English

如何使用Docker对MongoDB启用访问控制(Plesk)

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

How do I enable access control for my MongoDB server? 如何为我的MongoDB服务器启用访问控制? This line shows up in the log: 此行显示在日志中:

CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. CONTROL [initandlisten] **警告:未为数据库启用访问控制。 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. I CONTROL [initandlisten] **对数据和配置的读写访问不受限制。

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. 我使用Plesk启动MongoDB,但是我已经阅读了他们的手册,但是它没有告诉我如何启用访问控制,因为我只能通过Plesk控制面板添加环境变量和卷映射,例如/ data / db和/ 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. 我看到以下目录:docker-entrypoint-initdb.d,但我不知道该放在哪里。 Also packages that I installed inside the container like vim don't persist and are lost after a restart. 另外,我安装在容器内的软件包(如vim)不会保留,并且在重启后会丢失。

Furthermore I have no idea where Plesk is storing the docker-compose.yml file. 此外,我不知道Plesk在哪里存储docker-compose.yml文件。 Is this a file that only belongs inside a image file? 这是仅属于图像文件内部的文件吗?

If I change the /etc/mongod.conf and add this: 如果我更改/etc/mongod.conf并添加以下内容:

security: authorization: enabled

nothing happens after restart, could I get some help with this? 重新启动后什么都没有发生,请问我可以帮忙吗?

system information: 系统信息:

  • Plesk Onyx 17.8.11 Update 25 Plesk y玛瑙17.8.11更新25
  • Host: CentOS 7.5.1804 主机:CentOS 7.5.1804
  • Container: Ubuntu 16.04 容器:Ubuntu 16.04
  • Docker version 18.06.1-ce, build e68fc7a Docker版本18.06.1-CE,内部版本e68fc7a

You should read the library/mongo image documentation : https://hub.docker.com/_/mongo/ 您应该阅读库/ mongo映像文档: 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). 如果要使用自己的mongo配置文件,请将其放在/etc/mongo/mongod.conf之类的容器中(带有volume或COPY)。 After that you have to tell to mongo to use it as configuration file : 之后,您必须告诉mongo将其用作配置文件:

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

Or in docker-compose : 或者在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. 对于Plesk docker-compose.yml的位置,我无济于事,请尝试使用find命令。

I hope it will help you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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