Connect to mongoDB Server which runs in a Docker container

201 Views Asked by At

I am trying to connect to MongoDB server which is running in a Docker container on my windows 10 machine. However when I try to connect to localhost:27017 I get an error. I wonder what am I missing?

enter image description here

enter image description here

I tried to connect to localhost:27017

1

There are 1 best solutions below

0
The_flash On BEST ANSWER

you need to expose the port of your docker container so something like docker run -p 27017:27017 ...

https://docs.docker.com/engine/reference/commandline/run/