DEV Community

Discussion on: Docker Tip - How to use the host's IP Address inside a Docker container on macOS, Windows, and Linux

Collapse
 
ahmadharis4u profile image
Ahmad Haris • Edited

I tried this method:
$ export DOCKER_GATEWAY_HOST=172.17.0.1
put a new env docker container:
HOST_IP=${DOCKER_GATEWAY_HOST:-host.docker.internal}

When the docker runs, it shows HOST_IP=host.docker.internal

$ docker exec <container> env | grep HOST
HOST_IP=host.docker.internal
Enter fullscreen mode Exit fullscreen mode

The same is picked up by my python code.
Does this (host.docker.internal) also needs to be resolved to get the actual host IP?