问题
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