Can't access docker container on virtualbox from Internet
I have ToolBox installed on Windows 10.
Have created machine, and Nginx container, opened outside on port 8000.
Docker machine's IP is 192.168.99.100
, container's IP is 172.17.0.2
.
I can access Nginx from Windows as 192.168.99.100:8000
. Even more, I can access from Windows host directly to 172.17.0.2:80
. Also I can access Internet from inside the container.
At all the configuration is as following:
Container (Nginx) Docker Host (VirtualBox) Host (Windows 10) Router
172.17.0.2:80 <-----------> 172.17.0.1 (docker0)
10.0.2.15 (eth0)
192.168.99.100:8000 (eth1) <------> 192.168.99.1 (Ethernet 2, VirtualBox Host-Only Ethernet Adapter)
192.168.1.3 (Ethernet, Intel Hardware Adapter) <--------------------> 192.168.1.1
<Internet static IP address> <-----------> Provider
The problem is that I can't connect Nginx ouside of Windows host. Tried telnet 192.168.1.3 8000
from router - connection refused.
I have no any antivirus on Windows machine, and firewal is switched off.
Solution 1:
After a time have fount solution myself :)
VirtualBox -> Machine settings -> Network -> Adapter 1 (NAT) -> Advanced, Port Forwarding
Add rule like http
on the screenshot:
Rule ssh
has been automatically added by docker-machine create
.
The last quesion is how to add http
rule automatically when docker creates container with ports exposed.