问题描述
以下示例:
尝试连接到mongoDB时: mongo ip:27017
(其中ip是boot2docker ip的名称)+来自docker的端口号ps:
When trying to connect to mongoDB with: mongo ip:27017
(where ip is the name from boot2docker ip) + the port number from docker ps:
27017 / tcp
或与-P
0.0.0.0:49155-> 27017 / tcp
27017/tcp
or with -P
0.0.0.0:49155->27017/tcp
无论哪种方式,我都会收到以下错误:
Either way I get the following errors:
错误:无法连接到服务器ip:27017(ip),连接尝试
在src / mongo / shell / mongo.js失败:148异常:连接失败
Error: couldn't connect to server ip:27017 (ip), connection attempt failed at src/mongo/shell/mongo.js:148 exception: connect failed
推荐答案
我使用端口27017而不是49155(doh,端口转发)
I was using port 27017 instead of 49155 (doh, port forwarding)
0.0。 0.0:49155-> 27017 / tcp
0.0.0.0:49155->27017/tcp
感谢蔡司
这篇关于无法连接到docker容器中运行的mongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!