I am working on a Rest API and trying to connect to a MongoDb Docker container. I am on a Windows 10 machine and managed to get Docker up and running using Bash and Oracle Virtualbox VM. I ran $ docker run --rm --name mongo -d -p 27017:27017 -v mongodbdata:/data/db mongo:4.0.4 in Bash.
I ran docker inspect and the ports are exposed as follows:
"NetworkMode": "default",
"PortBindings": {
"27017/tcp": [
{
"HostIp": "",
"HostPort": "27017
In network settings I have
NetworkSettings": {
"Bridge": "",
"SandboxID": "f7d140fc6f524c8e854ced371c19ff4661f899bc96a42f7e817b301a9a514887",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"27017/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "27017"
}
]
},
"SandboxKey": "/var/run/docker/netns/f7d140fc6f52",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "fafa4bd9c05743874fa6783fce5b40c74cea0032cf51f35182efdc5eafd3156e",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2"
I am using c# Visual Studio Code and try to connect to the MongoDb Extension with the connection mongodb://locahost:27017 but I am getting ERRCONN REFUSED. I have tried using all combos of Mongodb:// localhost, 127.0.0.1, 172.17.0.2 and 0.0.0.0 but no luck. Also when I run the API I am getting "port 27017" actively refused the connection".
I am concerned there is some sort of conflict between Windows10, Bash, VS Code and Docker and they can't talk to each other.
Any help would be much appreciated.