Cannot connect to Mongo docker instance via mono client on mac

I installed the Mongo docker image and ran it using these commands (mac boot2docker installed)

docker pull mongo

and

docker run --name some-mongo -d mongo

but now I want to connect to it through the mongo client:

mongo --port 27017 --host 127.0.0.1

but I get this error message:

MongoDB shell version: 3.0.4
connecting to: 127.0.0.1:27017/test
2015-07-27T14:22:24.088+0300 W NETWORK  Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-07-27T14:22:24.094+0300 E QUERY    Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
    at connect (src/mongo/shell/mongo.js:181:14)
    at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed

It is clear to me that Docker does not detect ports, since telnet before 27017 on the local host does not work either.

What am I doing wrong?\

+4
source share
2 answers

You have 2 problems:

Like h3nrik, you must connect to the VM2 bootockdocker address. If you do not know this, use the following command:

boot2docker ip

And your port is not open .

Your command Docker runshould look like this:

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

+5
source

127.0.0.1 IP- boot2docker. 192.168.59.103. , IP- , boot2docker ip.

. , run:

docker run --name some-mongo -d mongo

- , , . ( mongodb):

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

Source: https://habr.com/ru/post/1599865/


All Articles