Reputation: 712
Please help me with this. I tried the following steps, but I am not able to connect to MongoDB.
docker run -p 27017:27017 --name my-mongo -d mongo:latest
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my-mongo
172.17.0.2
.It looks like you are trying to access MongoDB over HTTP on the native driver port.
I am stuck here.Thanks
Upvotes: 0
Views: 1073
Reputation: 2283
The IP Address you are trying to access is the container's private ip that is only accessible from within the docker network.
Using the parameter -p
that you're specifying on the docker run
you're telling docker to map a local port on your host to the port specified on the container, in this case local port 27017
to container port 27017
and after that you can access it with localhost
: http://localhost:27017
Read more about this here: https://docs.docker.com/config/containers/container-networking/
Upvotes: 1