我一直在尝试使用以下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
This is the image of the container configuraion in bluemix
你能告诉我为什么我无法连接吗?我做错了吗?
答案 0 :(得分:1)
您遇到的错误是因为端口27017未在IBM Containers中打开。 我建议您使用IBM Bluemix Support打开支持票,并要求打开此端口,或者您可以向IBM Bluemix支持团队查询您可以使用的备用开放端口。
您可以通过以下链接打开支持服务单:
答案 1 :(得分:0)
我相信你只需要使用私有IP作为容器。恩。 10.x.x.x.如果您的应用程序也在IBM Containers中运行,则应该打开端口27017。我意识到在您自己的机器上本地测试这可能会很痛苦,并且更容易让公共IP地址打开端口27017。