带有Mongodb连接的Bluemix IBM容器失败



我一直在尝试从以下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 中容器配置的图像

你能告诉我为什么我不能接通电话吗?我做错什么了吗?

您遇到的错误是因为端口27017未在IBM Containers中打开。我建议您向IBM Bluemix support打开支持票证,并要求打开此端口,或者您可以向IBM Bluemix support团队查询您也可以使用的其他开放端口。

您可以在以下链接中打开支持票证:

http://ibm.biz/bluemixsupport

我相信您将不得不为容器使用私有IP。例如10.x.x.x。如果您的应用程序也在IBM Containers中运行,那么端口27017应该是打开的。我意识到,当在自己的机器上进行本地测试时,这可能会很痛苦,而且只需要打开27017端口的公共IP地址会更容易。

最新更新