【发布时间】:2016-02-05 11:13:37
【问题描述】:
目前正在考虑在容器中部署 mongo。到目前为止,我的文件看起来像,
############################################################
# Dockerfile to build Mongo Containers
# Based on Ubuntu
############################################################
# Set the base image to Ubuntu
FROM ubuntu:14.04
# File Author / Maintainer
MAINTAINER Maintaner felix001
# Create repo file
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list
# Update the default application repository sources list
RUN apt-get update && apt-get install -y \
mongodb-org \
vim
# Create the MongoDB data directory
RUN mkdir -p /data/db
# Expose port 27017 from the container to the host
EXPOSE 27017
# Set usr/bin/mongod as the dockerized entry-point application
ENTRYPOINT ["/usr/bin/mongod"]
但是我需要锁定 mongo,因此您需要密码才能执行任何管理操作并创建数据库/用户。所以我的问题是 2 倍,
-
保护的最佳方法是什么?目前为止,
vim /etc/mongod.conf + auth = true use admin db.createUser({ user:"admin", pwd:"secretpassword", roles: ["dbAdminAnyDatabase","clusterAdmin"]}) use example db.createUser({ user:"user1", pwd:"abc123", roles:["readWrite"] }) 将其添加到 Dockerfile 的最佳方法是什么?
谢谢,
【问题讨论】: