我一直在尝试通过以下 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 上运行并为其分配公共(public) 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
你能告诉我为什么我无法建立连接吗?我做错了什么吗?
最佳答案
您遇到的错误是因为端口 27017 在 IBM Containers 中未打开。 我建议您通过 IBM Bluemix Support 打开支持票并要求打开此端口,或者您可以向 IBM Bluemix 支持团队查询您也可以使用的替代开放端口。
您可以在以下链接中打开支持票:
关于mongodb - Bluemix IBM Container 与 Mongodb 连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33464466/