From Docker 17.06 onwards, a special Mac-only DNS name is available in docker containers that resolves to the IP address of the host. It is:
docker.for.mac.localhost
The documentation is here: https://docs.docker.com/docker-for-mac/networking/#httphttps-proxy-support