Docker for mac 1.12.0: how to connect to host from container

Had the same problem and being inexperienced in Docker and network configurations I struggled to get the various proposed solutions working. However since this update to Docker for Mac: Docker Community Edition 17.06.0-ce-mac18, 2017-06-28 (stable) I've found using the 'experimental' hostname docker.for.mac.localhost allows me to contact services running on the Mac host from within a container. Very useful for dev!


I am having the same problem and I've found this

https://docs.docker.com/docker-for-mac/networking/#/known-limitations-use-cases-and-workarounds

Notice paragraph 'I want to connect from a container to a service on the host'

I haven't yet tried it because I am looking for a more concrete solution (anyway other than adding alias to my lo address)...

If somebody has something on it please inform!


latest:DNS name host.docker.internal should be used for host resolution from containers. Older aliases (still valid) are deprecated in favor of this one. (See https://tools.ietf.org/html/draft-west-let-localhost-be-localhost-06). docker.for.mac.host.internal should be used instead of docker.for.mac.localhost from Docker Community Edition 17.12.0-ce-mac46 2018-01-09. this allows you to connect to service running on your on mac from within a docker container.please refer below links

understanding the docker.for.mac.localhost behavior

release notes