Docker Community Forums

Share and learn in the Docker community.

Docker for Mac: accessing machines host alias from inside a container

I am trying to access alias in my /etc/hosts from inside a docker container, I have used host.docker.internal but that resolves to localhost, my machines /etc/hosts looks like this:

#i can reach with using host.docker.internal       loclalhost

#cannot reach these hostnames        local-servce        local-postgres        local-redis        local-elasticsearch        local-grcp

I cannot call the host names from inside the container, where as on my Linux machine I am able to use network_mode: host. I understand that network_mode is not available for mac and there is the DNS name that is exposed to get localhost, but is there a way to connect to these hostnames?