1. 程式人生 > >Docker mongodb Dockerfile ubuntu

Docker mongodb Dockerfile ubuntu

docker

技術分享圖片

1.目錄結構,把配置文件也放這裏,等下復制到image裏面去

2.mongod.conf

net:
  port: 27017
  bindIp: 0.0.0.0
security:
  authorization: enabled
systemLog:
  destination: file
  path: "/data/log/mongod.log"
  logAppend: true
storage:
  dbPath: "/data/db"
#processManagement:
#  fork: true

3. dockerfile

#FROM debian:wheezy
FROM ubuntu

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb

RUN apt-get update 

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

RUN echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list

RUN apt-get update

RUN apt-get install -y mongodb-org

RUN mkdir -p /data/db /data/log /data/configdb     && chown -R mongodb:mongodb /data/db /data/log /data/configdb
VOLUME /data/db /data/log /data/configdb

COPY ./mongod.conf /data/configdb
#COPY docker-entrypoint.sh /entrypoint.sh
#ENTRYPOINT ["/entrypoint.sh"]

EXPOSE 27017
CMD ["mongod"]

http://www.waitingfy.com/archives/3376

docker executes two commands at a time


Docker mongodb Dockerfile ubuntu