Connect to host mongodb from docker container
You can use: 172.17.0.1
as it is the default host ip that the containers can see. But you need to configure Mongo to listen to 0.0.0.0
.
From docker 18.03 onwards the recommendation is to connect to the special DNS name host.docker.internal
For previous versions you can use DNS names docker.for.mac.localhost
or docker.for.windows.localhost
.
change the bindIp from 127.0.0.1 to 0.0.0.0 in /etc/mongod.conf. Then it will work