Connecting Robo 3T to Docker MongoDB container
It wasn't until I had to reboot my Mac that I realised that I'd still had a local instance of MongoDB running, therefore the I wasn't connecting to my Docker instance of MongoDB but my local (Brew installed) instance.
Once I'd seen @Artjom Zabelin answer here and "Don't forget to map port to host port"
docker run --name some-mongo -p 27017:27017 -d mongo
It connected to MongoDB running my container.
@Frank Yucheng Gu was correct that I needed 'localhost'.
To connect, you should simply connect with localhost:27017
on Robo3T.
The problem originates in the confusion between a container's internal IP and its external IP. The internal IP is your container's address in the docker network, which is isolated from you host network (unless explicitly bridged). When you do the docker inspect
command, you grabbed the container's IP on the docker network.
Your container is listening on 0.0.0.0:32844
in the docker network, and exposed to the host with a port mapping to port 27017. So if you have another container in the docker network, you should access your service with 172.17.0.2:32844
. But if you have anything outside of the docker network, you should access your mongodb with either localhost:27017
or [your host IP]:27017
.
Hope this helps!