This is more a bookmark than a post - but I’d like to write it down explicitly since everytime I need this I have to google it (and cutting through the false positivies sucks).
From 18.03 onwards our recommendation is to connect to the special DNS name
host.docker.internal
, which resolves to the internal IP address used by the host.
This was taken from the docker-for-mac documentation were you can find more details.
Notice: This also works for locally mapped ports of other containerized services (and thus is handy for using containerized CLI tools with existing stacks).
Notice: This is not just a docker-for-mac thing but also works for docker-for-win