0

I've created a mongodb container in docker with this command:

from host1:

docker run -p 27017:27017 mongo --bind_ip_all

I know host1.ip.

I find out container id with:

docker inspect <mongo_id>

For example container.ip = 172.17.0.2

From host2

if I run:

mongo --host: <host1.ip>:27017 

it works

But if run

mongo --host: 172.17.0.2:27017 

I get this error:

MongoDB shell version v3.6.3 connecting to: mongodb://172.17.0.2:27017/ 2018-06-20T13:54:17.111+0200 W NETWORK [thread1] Failed to connect to 172.17.0.2:27017, in(checking socket for error after poll), reason: No route to host 2018-06-20T13:54:17.111+0200 E QUERY [thread1] Error: couldn't connect to server 172.17.0.2:27017, connection attempt failed : connect@src/mongo/shell/mongo.js:251:13 @(connect):1:6 exception: connect failed

I'd know why it doesn't work and what i can do to manage that

Christian Sicari
  • 121
  • 2
  • 13

0 Answers0