0

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?

1

I'd point to the difference between -p 8000:80 and http://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/

Note: Given that the container does not have its own IP-address when using host mode networking, port-mapping does not take effect, and the -p, --publish, -P, and --publish-all option are ignored, producing a warning instead.

If you use the host network mode for a container, that container’s network stack is not isolated from the Docker host (the container shares the host’s networking namespace), and the container does not get its own IP-address allocated. For instance, if you run a container which binds to port 80 and you use host networking, the container’s application is available on port 80 on the host’s IP address.

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.

|improve this answer|||||
  • Sorry, I just written it wrong port in description, i had updated the question. But issue is still same. – Kathak Dabhi Jan 2 at 9:04
  • Can you access 192.168.13.39:8080 (Ubuntu, wich should be the right access point) from 192.168.11.39 (Windows)? – Ictus Jan 2 at 9:13
  • No, It is giving error connection refushed – Kathak Dabhi Jan 2 at 9:31
  • Can you access 192.168.13.39 (Ubuntu) from 192.168.11.39 (Windows)? – Ictus Jan 2 at 9:41
  • Yes, I can access that – Kathak Dabhi Jan 2 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.