How to connect from docker-compose to Host PostgreSQL?
This would have worked if you were on linux OS. But this won't work on Mac or Windows. The thing is that when you use --net=host
, you still are not on host network. That is the limitation of how docker for windows work
Instead of localhost you need to use docker.for.win.localhost
as the host. This is a special DNS name which is available on Docker for Windows when you want to refer to the host localhost
Updated Apri, 2018
According to the document, from version 18.03 onwards, using host.docker.internal
as DNS works for me, without specifying neither --net=host
or network_mode: "host"