我有Dockerized MongoDB并尝试从同一主机上运行的另一个容器访问它。但是我在容器上收到以下错误:
com.mongodb.MongoException$Network: can't call something : /1.2.3.4:27017/admin
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:227)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
at com.mongodb.DB.command(DB.java:160)
at com.mongodb.DB.command(DB.java:183)
at com.mongodb.DB.command(DB.java:144)
at com.mongodb.DB.command(DB.java:195)
at com.mmi.epg.utils.MongoDB.getDbVersion(MongoDB.java:117)
at com.mmi.epg.utils.MongoDB.<init>(MongoDB.java:73)
at com.mmi.epg.utils.MongoDB.getInstance(MongoDB.java:105)
Caused by: java.io.EOFException
at org.bson.io.Bits.readFully(Bits.java:37)
at org.bson.io.Bits.readFully(Bits.java:28)
at com.mongodb.Response.<init>(Response.java:39)
at com.mongodb.DBPort.go(DBPort.java:128)
at com.mongodb.DBPort.call(DBPort.java:79)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:218)
... 13 more
其中fcdfd39baedb是访问mongoDB的服务容器。我在mongod.conf中有这一行。
#bind_ip=127.0.0.1
为什么服务使用内部IP地址并且在此之前有容器ID来调用MongoDB实例?我在这里做错了吗?
更新:请在下面找到我的Dockerfile
FROM tveuser/tve-repository:tve-centos
MAINTAINER karthik.jayaraman "karthik.jayaraman@xyz.com"
VOLUME ["/data/db"]
# Expose port #27017 from the container to the host
EXPOSE 27017
ADD /scripts/mongodb.repo /etc/yum.repos.d/
ADD /conf/mongod.conf /etc/
ADD supervisord.conf /etc/
RUN yum install -y mongo-10gen mongo-10gen-server &&\
mkdir -p /data/db
CMD supervisord -c /etc/supervisord.conf
我已经更新了我的问题。我可以从我的服务telnet IP和端口号,但无法连接到MongoDB。会感激一些帮助。