I had a virtual machine with Ubuntu which is installed inside windows 10 host and accessible to all pcs in LAN using its IP address. Inside Ubuntu I'm running the docker containers within docker-machine. And Docker machine is only accessible in Ubuntu system. Architecture can be found in provided image link.
Architecture of LAN-UbuntuVM-Docker-Machine https://ibb.co/LzTbFzL
Now I'm running a docker container inside docker machine
docker run -d -p 8000:80 nginx
Which bind ports 8000 of Docker Machine to containers 80 and On Ubuntu machine I can access the container with http://192.168.99.100:8000 from browser in Ubuntu machine.
I had added an entry to /etc/hosts file to give domain name to docker-machine
...
192.168.99.100 docker.devv
...
So now I can access the docker container with http://docker.devv:8000/ inside Ubuntu virtual machine.
Now I want to access the docker containers from Windows host machine using domain name like "http://docker.devv:8000/"
I tried by adding the Ubuntu VM ips with hostname "docker.devv" to winodws etc\host file but it is not working.
Anyone can help with this?
Best Answer
I'd point to the difference between
-p 8000:80
andhttp://docker.devv:8080/
?8000 vs 8080
EDIT:
192.168.99.100 should not be directly accessed from Windows unless some routing rules added to Windows and Ubuntu machines.
So please, check you can access to Ubuntu machine's IP on the exposed port from the Windows machine. If that works then we need to fix a domain resolution issue. If not, please check as pointed out in a comment from Ganesh Kathiresan if you are using bridged networking, and check if there is a firewall active.
EDIT:
If you use the host network mode for a container the things are diferent: https://docs.docker.com/network/host/
So, please try to access to ubuntu in 80 port from windows.
EDIT:
As you can access the 80 port, (if no other HTTP service answering in ubuntu), the problem was the host network mode on the container, that disallows -p flag to work, as the container is using the same IP of the host.
You can leave it that way but if you plan to add other containers and need to use the same HTTP 80 port on them I'll suggest using bridged mode on those.