Connect to host mongodb from docker container

后端 未结 2 401
[愿得一人]
[愿得一人] 2020-12-15 18:09

So I want to connect to my mongodb running on my host machine (DO droplet, Ubuntu 16.04). It is running on the default 27017 port on localhost.

I then u

相关标签:
2条回答
  • 2020-12-15 18:34

    change the bindIp from 127.0.0.1 to 0.0.0.0 in /etc/mongod.conf. Then it will work

    0 讨论(0)
  • 2020-12-15 18:39

    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.

    0 讨论(0)
提交回复
热议问题