如何在Win7中通过Internet从Docker服务器查看网页

时间:2018-11-06 16:10:54

标签: docker

如何在Win7中从互联网查看Docker服务器的网站?

docker toolbox中安装win7 64bit
我无法从互联网访问docker服务器。

我可以从互联网上毫无问题地在win7中看到本机服务器的网页。

$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL      SWARM   DO
CKER        ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v1
8.06.1-ce

$ docker ps
CONTAINER ID        IMAGE                     COMMAND                  
CREATED
       STATUS              PORTS
NAMES
65b815ffa17c        richarvey/nginx-php-fpm   "docker-php-entrypoi"   4 hours ag
o         Up 4 hours          80/tcp, 443/tcp, 9000/tcp, 0.0.0.0:8000->8000/tcp
web

主机(win7)<---> VM guest虚拟机<---> docker容器

我相信
适配器1 NATVM guest <---> docker container的一部分。
适配器2 host-onlyhost (win7) <---> VM guest的一部分。

所以在这种设置下,我永远无法通过外部互联网连接Docker容器。

尝试1

如果我尝试从bridge更改适配器2 host-only,它将产生错误或跳回到host-only

enter image description here

enter image description here

尝试2

从Windows的适配器更改IP

enter image description here

我更改了VirtualBox Host-Only Network #2

1)转到控制面板->网络和Internet->网络连接
2)右键单击VirtualBox Host-Only Network #2,然后选择属性
3)选择“ Internet协议版本4(TCP / IPv4)”,然后单击“属性”
4)点击obtain an IP address automatically

enter image description here

结果:

它会生成一个具有原始参数的VirtualBox Host-Only Network #3适配器...

$ docker-machine start default
Starting "default"...
(default) Check network to re-create if needed...
(default) Windows might ask for the permission to create a network adapter. Some
times, such confirmation window is minimized in the taskbar.
(default) Found a new host-only adapter: "VirtualBox Host-Only Ethernet Adapter
#3"
(default) Windows might ask for the permission to configure a network adapter. S
ometimes, such confirmation window is minimized in the taskbar.
(default) Windows might ask for the permission to configure a dhcp server. Somet
imes, such confirmation window is minimized in the taskbar.
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.

尝试3

1)转到控制面板->网络和Internet->网络连接
2)右键单击VirtualBox Host-Only Network #2,然后选择属性
3)选择“ Internet协议版本4(TCP / IPv4)”,然后单击“属性”
4)Give to the adapter a static IP address在您当前的真实网络上有效。确保DNS也有效,以便容器能够解析Web上的域

结果:没用,就像尝试2

ref

尝试4

...


更新 好的,我知道为什么。

我的防火墙设置错误。 DMZ应该位于主机IP上,而不是VM IP上。

1 个答案:

答案 0 :(得分:0)

从您本地的

docker exec -it <CONTAINER-ID> sh