Cannot connect Robomongo using MongoDB docker imag

2020-06-13 09:31发布

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

2条回答
欢心
2楼-- · 2020-06-13 09:55

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.

查看更多
相关推荐>>
3楼-- · 2020-06-13 09:58

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

container id is sha256

查看更多
登录 后发表回答