Cannot connect Robomongo using MongoDB docker image

我只是一个虾纸丫 提交于 2019-12-05 18:37:16

问题


I am running mongo docker image that I pulled from docker hub mongo image

It works ok but when I start Robomongo I cannot connect to localhost. With following error message:

Cannot connect to the MongoDB at localhost:27017.

Error: Network is unreachable

I appreciate any help, thanks.

EDIT: I solved the issue by using the following command:

docker run -p 27017:27017 --name mongo_instance_001 -d mongo


回答1:


Don't forget to map port to host port:

docker run --name some-mongo -p 27017:27017 -d mongo

Then

docker-machine ip

gives me 192.168.99.100

Type in terminal

mongo 192.168.99.100

prints

MongoDB shell version: 3.2.4
connecting to: 192.168.99.100/test
Server has startup warnings: 
2016-08-22T07:35:20.214+0000 I CONTROL  [initandlisten] 
2016-08-22T07:35:20.214+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-08-22T07:35:20.214+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-08-22T07:35:20.214+0000 I CONTROL  [initandlisten] 
2016-08-22T07:35:20.214+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-08-22T07:35:20.214+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-08-22T07:35:20.214+0000 I CONTROL  [initandlisten]

I also tested with robomongo. I can connect without a problem.




回答2:


you can find docker-machine ip just typing this command docker inspect

container id is sha256



来源:https://stackoverflow.com/questions/39073521/cannot-connect-robomongo-using-mongodb-docker-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!