Getting the IP of docker virtual host machine (VM) on Windows.

To get docker IP you can take a pick on your windows host file through PowerShell terminal. Open terminal and run:

cat C:\Windows\System32\drivers\etc\hosts | findstr "docker"

Or navigate to C:\Windows\System32\drivers\etc folder and open hosts file

file. Docker will automatically define its VM IP address with in the above file.

In my case, that would be:

# Added by Docker Desktop
192.168.1.101 host.docker.internal
192.168.1.101 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

You can also try to get Docker VM IP running:

On Linux (or WSL) it would be placed in /etc/hosts file. To view docker IP you would run:

cat /etc/hosts | grep docker

Alternatively you could run

ip a | grep docker0

Note! Always make sure you run http (if not configure https) Sometimes the port :80 will temporally not work on localhost or even on docker VM IP address. It is safer to run containers on other ports like :8080. Always clear the browser cache as it might serve you some old content.

Also, you might be interested in reading posts:
How to check what service is listening on port :80 on Windows host
How to get docker container IP address

0
Would love your thoughts, please comment.x
()
x