I am trying to connect to my docker mongo image, I installed mongodb in local, and added the mongodb bin path to windows path environment variable. And I am doing below steps
cd <docker-location>
docker login
docker ps
-- to check already mongo running
docker pull myrepo/mymongo-image:1.0
docker run -p 27017:27017 -d --net=host --name=mytestDB myrepo/mymongo-image:1.0
docker logs mytestDB
Output: MongoDB starting : pid=6 port=27017 dbpath=/data/db 64-bit host=moby docker ps Output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
34598734598 myrepo/mymongo-image:1.0 "/bin/sh -c /usr/bin/" 12 hours ago Up About a minute mytestDB
start mongo in local:
mongo --port 27017
But I am getting error like this:
MongoDB shell version: 3.2.1
connecting to: 127.0.0.1:27017/test
2016-10-13T20:04:12.273+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2016-10-13T20:04:12.277+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:226:14
@(connect):1:6
exception: connect failed
Please let me know where I did mistake.