I have a similar problem discussed in Cannot connect to MongoDB in docker.
- Windows host
- Docker Toolbox, so it is using VirtualBox
I used docker run --name mongo2 -p 127.0.0.1:27017:27017 mongo
to create the MongoDB container.
When I connect to the container (docker -it mongo2 /bin/bash
), I can connect to Mongo via mongo localhost:27017
.
I also checked with netstat that Mongo is listening on 0.0.0.0:27017, not only localhost.
Still, I'm not able to connect from my Windows host to the container. I even tried to disable Windows firewall and still nothing:
rs@ausus:~$ telnet localhost 27017
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
Any ideas?