我有以下图片:
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install apt-transport-https -y
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.6.list
RUN apt-get update
RUN apt-get install -y mongodb-org=3.6.2 mongodb-org-server=3.6.2 mongodb-org-shell=3.6.2 mongodb-org-mongos=3.6.2 mongodb-org-tools=3.6.2
RUN mkdir -p /data/db
EXPOSE 27017
CMD ["--port 27017", "--smallfiles"]
ENTRYPOINT usr/bin/mongod
使用以下命令运行:
docker run --rm -ti --security-opt = seccomp:unconfined -p27017:27017 -p28017:28017 --name mong --rm mong
运行后我看到以下警告:
WARNING: This server is bound to localhost.
Remote systems will be unable to connect to this server.
Start the server with --bind_ip <address> to specify which IP
addresses it should serve responses from, or with --bind_ip_all to
bind to all interfaces. If this behavior is desired, start the
server with --bind_ip 127.0.0.1 to disable this warning.
我尝试在入口点之前添加CMD ["--bind_ip_all"]
,但它没有帮助。如何将MongoDB暴露给hostmachine?
答案 0 :(得分:1)
尝试使用:--bind_ip 0.0.0.0
您的CMD成为:
CMD ["--port 27017", "--smallfiles", "--bind_ip", "0.0.0.0"]