0
en1 (local machine): 192.168.1.5 /24 vboxnet0: 192.168.99.1 /24 docker-machine ip: 192.168.99.100 docker daemon: tcp://192.168.99.100:2376 docker0 (bridge): 172.17.0.1 

then i run the container:

docker run -p 5000:5000 friendlyhello & container's ip: 172.17.0.2/16 

But I can only see the webpage running at 192.168.99.100:5000, and only on my local machine, not from any other machine connected to the LAN. Additionally, the web-app friendlyhello is using the microframework Flask to serve pages.

How can I view the webapp from a browser on another machine on the LAN or Internet?

1
  • Maybe port 5000 is being blocked on your local machine? Commented Nov 14, 2017 at 20:30

1 Answer 1

0

Your container is running inside the VM created by docker-machine and although you've published port 5000 for your container, the ports on your docker-machine are not directly accesible from the rest of the LAN. You must forward port 5000 (or any other port that you prefer) in your localhost to port 5000 in the VM in order to get the traffic from the rest of the LAN.

As suggested in this answered question you should use something like this:

docker-machine ssh default -L 5000:localhost:5000 
Sign up to request clarification or add additional context in comments.

3 Comments

this is a valid solution...but can you explain how does docker map 172.17.0.2 (ip on same subnet as docker0) to 192.168.99.100 within the vm environment?
When you publish a port like 5000 in your example, Docker creates automatically a nat rule in the iptables firewall that is running in your docker-machine VM which is the responsible of the mapping. For example I've launched a docker container with nginx like this: docker run --publish 8010:80 nginx Once the docker container is running, Docker has created a new rule (I run iptables -t nat -L -n) and here is the rule: DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8010 to:172.17.0.2:80 That rule maps 192.168.99.100 port 8010 to 172.17.0.20 port 80.
You have more information about this mapping in Docker docs

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.