在Docker Centos上安装后,Mongo不运行:无法连接到127.0.0.1:27017

我为我的应用程序运行一个CentOS镜像,其中一个是mongo。 当我运行图像时,所有其他的依赖似乎运行。 但是,mongo服务似乎不运行。 我已经看到类似的问题(与docker不相关),但没有任何解决scheme为我工作。 我的主机是一个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 

在构buildDockerfile之后运行Contaier时运行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 

任何帮助,将不胜感激。