MongoDB连接的Bluemix IBM Container失败

我一直在试图从Dockerfile中准备一个包含在Docker容器中的mongodb的图片:

# Dockerizing MongoDB: Dockerfile for building MongoDB images # Based on ubuntu:latest, installs MongoDB following the instructions from: # http://d...content-available-to-author-only...b.org/manual/tutorial/install-mongodb-on-ubuntu/ # Format: FROM repository[:version] FROM ubuntu:latest # Format: MAINTAINER Name <email@addr.ess> MAINTAINER Name <my@gmail.com> # Installation: # Import MongoDB public GPG key AND create a MongoDB list file RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 RUN echo "deb http://r...content-available-to-author-only...b.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee/etc/apt/sources.list.d/mongodb-org-3.0.list # Update apt-get sources AND install MongoDB RUN apt-get update && apt-get install -y mongodb-org # 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"] 

在本地运行之后,它完全可以正常工作,但在Bluemix上运行并将其分配给公有IP地址时,连接尝试的结果会出现以下错误:

 $ mongo --host 134.168.37.176 MongoDB shell version: 2.6.3 connecting to: 134.168.37.176:27017/test 2015-11-01T17:24:10.557+0100 Error: couldn't connect to server 134.168.37.176:27017 (134.168.37.176), connection attempt failed at src/mongo/shell/mongo.js:148 exception: connect failed 

这是bluemix中容器configuration的图像

你能告诉我为什么我不能连接吗? 难道我做错了什么?

您遇到的错误是因为端口27017未在IBM Containers中打开。 我build议您使用IBM Bluemix支持人员打开支持凭单,并要求打开此端口,或者您可以与IBM Bluemix支持团队联系,了解可以使用的另一个开放端口。

您可以在以下链接中打开支持服务单:

http://ibm.biz/bluemixsupport

我相信你将不得不使用私人IP的容器。 恩。 10.xxx如果应用程序也在IBM Containers中运行,则应打开端口27017。 我意识到在自己的机器上进行本地testing时,这可能会很麻烦,只需公开IP地址开放端口27017就可以了。