我正在为我的应用运行一个具有多个依赖项的CentOS映像,其中一个是mongo。当我运行图像时,所有其他依赖项似乎都会运行。但是,mongo服务似乎没有运行。我见过类似的问题(与docker无关),但这些解决方案都不适用于我。我的主机是Ubuntu 16.04,如果有任何用途,知道这一点。这是deets:
Dockerfile:
FROM centos:latest
ENV container docker
RUN yum -y update
RUN yum -y install initscripts
RUN yum -y install systemd; yum clean all; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ “/sys/fs/cgroup” ]
CMD [“/usr/sbin/init”]
# Compilers and related tools:
RUN yum groupinstall -y "development tools"
# Libraries needed during compilation to enable all features of Python:
RUN yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel
# If you are on a clean "minimal" install of CentOS you also need the wget tool:
RUN yum install -y wget
# Python 3.6.0:
RUN wget http://python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz
RUN tar xf Python-3.6.0.tar.xz
RUN cd Python-3.6.0 && ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" && make && make altinstall
RUN mkdir -p /opt/python/Python-3.3/
RUN ln -s /opt/python/Python-3.3/python python3.6
#MongoDb
ADD mongodb-org-3.0.repo /etc/yum.repos.d/mongodb-org-3.0.repo
RUN yum install -y mongodb-org
EXPOSE 27017
#Phantom JS
RUN wget http://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
RUN mkdir -p /opt/phantomjs
RUN tar xvfj phantomjs-2.1.1-linux-x86_64.tar.bz2
RUN cd phantomjs-2.1.1-linux-x86_64 && cp -ar * /opt/phantomjs/. && ln -s /opt/phantomjs/bin/phantomjs /usr/bin/phantomjs && phantomjs -v
#JINJA
RUN python3.6 -m pip install Jinja2
CMD /usr/bin/mongod
Docker版本:
Client:
Version: 17.03.1-ce
API version: 1.27
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:14:09 2017
OS/Arch: linux/amd64
Server:
Version: 17.03.1-ce
API version: 1.27 (minimum version 1.12)
Go version: go1.7.5
Git commit: c6d412e
Built: Mon Mar 27 17:14:09 2017
OS/Arch: linux/amd64
Experimental: false
在构建Dockerfile后运行容器时运行mongo命令时出现的错误是:
MongoDB shell version: 3.0.14
connecting to: test
2017-05-04T11:27:33.199+0000 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-05-04T11:27:33.203+0000 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
任何帮助都将不胜感激。