mongodb - Bluemix IBM Container 与 Mongodb 连接失败

标签 mongodb docker ibm-cloud dockerfile

我一直在尝试通过以下 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 支持团队查询您也可以使用的替代开放端口。

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

http://ibm.biz/bluemixsupport

关于mongodb - Bluemix IBM Container 与 Mongodb 连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33464466/

相关文章:

python - python 中的 Cloudant 数据库监听器

mongodb - 如何使用 mgo 插入文档并获取返回值

linux - 修改正在运行的 Docker 容器的主机文件

ios - Bluemix Cloudant - 内部服务器错误

ios - 如何在 ionic.io 项目中使用 IBM Bluemix BMS 移动推送通知服务?

docker - 错误!在主处理程序列表和监听处理程序列表中都找不到请求的处理程序 'docker status'

python - 加载 http ://0. 0.0.0:27017 时 mac os 上的 Docker mongodb 连接被拒绝

mongodb - 仅获取 mongodb 中数组属性的第一项

python - 属性错误 : 'list' object has no attribute 'items' in a scrapy

python - 无法访问 docker 容器 Socket 挂起错误