2015-11-01 48 views
3

我一直在試圖製備含MongoDB的在泊塢容器從以下dockerfile圖像:Bluemix IBM集裝箱用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 protected]> 
MAINTAINER Name <[email protected]> 

# 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

你能告訴我爲什麼我無法建立連接?難道我做錯了什麼?

回答

1

您遇到的錯誤是因爲端口27017未在IBM Containers中打開。 我建議您使用IBM Bluemix支持人員打開支持憑單,並要求打開此端口,或者您可以與IBM Bluemix支持團隊聯繫,以獲取可以使用的替代開放端口。

您可以通過以下鏈接打開支持票:

http://ibm.biz/bluemixsupport

+0

是否有已發佈的所有當前打開的端口列表? –

+0

出於安全原因,這不會在外部發布。 –

0

我相信你必須只使用私有IP的容器。恩。 10.x.x.x.如果您的應用程序也在IBM Containers中運行,則應該打開端口27017。我意識到在自己的機器上進行本地測試時,這可能會很痛苦,並且只需要公開IP地址打開端口27017就會更容易。