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.