2016-02-05 79 views
2

当前正在考虑在容器中部署mongo。到目前为止,我的文件看起来像,在Docker容器中保护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"] 

不过,我需要,所以你需要一个密码来执行任何管理措施,并创建一个数据库/用户锁定蒙戈。所以我的问题是2倍,

  1. 什么是最好的安全方法?到目前为止,我有,

    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"] }) 
    
  2. 什么是将此添加到Dockerfile的最佳方法?

感谢,

回答