I am a newbie to Docker, Hence I need your assistance.
Issue: I am running docker on Windows to set up a grid, I am able to access the hub as local host (http://localhost:4444/grid/console), However when I am trying to access the same with the IP mentioned in the docker (http://172.23.0.2:4444/grid/console). It’s not working .
Thanks in Advance!
This is expected.
By default, a container doesnt share the network space of it’s host. So “localhost” in the container is not the same as “localhost” from the host. (there’s so many good reasons for that default…)
Yet you’re free to allow a container to share localhost with its host using
--network host in the command line.
Thanks @sebt3 for your quick response. However the same is not behavior in Linux container-i.e, - I launched VM of Ubuntu and executed container from there and i can access the same Hub IP in my host windows system.
That’s correct. Linux Docker containers don’t run natively on Windows because they require a Linux kernel to share. Linux containers only run on Linux and so Docker for Windows actually runs a Linux VM in the background so
localhost is pointing to the Linux VM host, not your Windows host. On a Linux system they run natively, hence the seemingly different behavior.