在尝试连接Docker容器中的MongoDb时,出现了连接被拒绝的情况。
以下是docker ps的输出:
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 21063296d7d8 mongo "/entrypoint.sh mongo" 44 minutes ago Up 29 minutes 0.0.0.0:57017->27017/tcp mongodb-dev
以下是docker logs mongodb-dev的片段:
2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] db version v3.0.7 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] git version: 6ce7cbe8c6b899552dadd907604559806aa2e9bd 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] build info: Linux ip-10-183-78-195 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 BOOST_LIB_VERSION=1_49 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] allocator: tcmalloc 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] options: {} 2015-11-28T05:36:36.365+0000 I NETWORK [initandlisten] waiting for connections on port 27017
以下是使用端口57017连接到docker中的MongoDB时出现的错误:
mongo localhost:57017
MongoDB shell version: 3.0.7 connecting to: localhost:57017/test 2015-11-27T22:09:22.733-0800 W NETWORK Failed to connect to 127.0.0.1:57017, reason: errno:61 Connection refused 2015-11-27T22:09:22.734-0800 E QUERY Error: couldn't connect to server localhost:57017 (127.0.0.1), connection attempt failed at connect (src/mongo/shell/mongo.js:181:14) at (connect):1:6 at src/mongo/shell/mongo.js:181 exception: connect failed
请告诉我这里缺少什么。谢谢您的帮助!
以下是docker ps的输出:
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 21063296d7d8 mongo "/entrypoint.sh mongo" 44 minutes ago Up 29 minutes 0.0.0.0:57017->27017/tcp mongodb-dev
以下是docker logs mongodb-dev的片段:
2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] db version v3.0.7 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] git version: 6ce7cbe8c6b899552dadd907604559806aa2e9bd 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] build info: Linux ip-10-183-78-195 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64 BOOST_LIB_VERSION=1_49 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] allocator: tcmalloc 2015-11-28T05:36:36.363+0000 I CONTROL [initandlisten] options: {} 2015-11-28T05:36:36.365+0000 I NETWORK [initandlisten] waiting for connections on port 27017
以下是使用端口57017连接到docker中的MongoDB时出现的错误:
mongo localhost:57017
MongoDB shell version: 3.0.7 connecting to: localhost:57017/test 2015-11-27T22:09:22.733-0800 W NETWORK Failed to connect to 127.0.0.1:57017, reason: errno:61 Connection refused 2015-11-27T22:09:22.734-0800 E QUERY Error: couldn't connect to server localhost:57017 (127.0.0.1), connection attempt failed at connect (src/mongo/shell/mongo.js:181:14) at (connect):1:6 at src/mongo/shell/mongo.js:181 exception: connect failed
请告诉我这里缺少什么。谢谢您的帮助!