连接到vmware

时间:2017-08-20 15:27:14

标签: macos docker vagrant virtualbox vmware

在我的Mac上,我在VMware中运行Windows Server 2016。在那里我在vagrant / Virtual Box中运行Ubuntu。在那里,我在一个带有nginx / uwsgi的docker容器中运行一个django应用程序。 Web服务器正在侦听9003,并且从Windows VM中运行的浏览器,我可以使用localhost:9003连接到Web服务器。我希望能够从Mac上运行的浏览器和本地网络上的其他计算机连接到它。在VMware网络设置中,我选择了Internet共享,与我的Mac共享。

在Windows VM中我看到了:

$ ipconfig

Windows IP Configuration


Ethernet adapter vEthernet (HNS Internal NIC):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::a088:5807:8265:722%11
   IPv4 Address. . . . . . . . . . . : 192.168.192.1
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :

Ethernet adapter Ethernet0:

   Connection-specific DNS Suffix  . : localdomain
   Link-local IPv6 Address . . . . . : fe80::440c:bbeb:3408:87a2%6
   IPv4 Address. . . . . . . . . . . : 172.16.88.128
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 172.16.88.2

Ethernet adapter VirtualBox Host-Only Network:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::d90e:3f15:2ff3:9c8%3
   IPv4 Address. . . . . . . . . . . : 192.168.56.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Tunnel adapter isatap.{128CE093-EDCD-4551-A68C-1ED0F721C48D}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter isatap.{C1972449-FA02-4CD9-A894-9F82BCD31099}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter isatap.localdomain:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : localdomain

在流浪汉VM中:

$ ifconfig
docker0   Link encap:Ethernet  HWaddr 02:42:6a:c7:10:cf
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:6aff:fec7:10cf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:87179 errors:0 dropped:0 overruns:0 frame:0
          TX packets:177348 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:17368120 (17.3 MB)  TX bytes:1072352935 (1.0 GB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:ac:f1:24
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feac:f124/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:890873 errors:0 dropped:0 overruns:0 frame:0
          TX packets:128642 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1203867192 (1.2 GB)  TX bytes:24867499 (24.8 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1296 (1.2 KB)  TX bytes:1296 (1.2 KB)

vetha7780cb Link encap:Ethernet  HWaddr 0e:7b:96:75:ae:68
          inet6 addr: fe80::c7b:96ff:fe75:ae68/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5808 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10063 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:13697486 (13.6 MB)  TX bytes:637891 (637.8 KB)

在泊坞窗容器中:

# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 0.0.0.0
        ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
        RX packets 10155  bytes 891257 (870.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5893  bytes 13702369 (13.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 0  (Local Loopback)
        RX packets 506  bytes 184179 (179.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 506  bytes 184179 (179.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我的Mac的本地IP是10.0.0.19。

从我的Mac上我尝试连接到localhost:9003,但是没有用。我还尝试了10.0.0.19,10.0.2.15,172.17.0.1,192.168.192.1,172.16.88.128和192.168.56.1,这些都来自我的Mac和本地网络上的另一台机器。一切都行不通。

我的Mac和Windows VM上的防火墙都被禁用。

如何从Mac和其他本地计算机连接到此服务器?

更新:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                   NAMES
87a9527a1a66        capgraph            "/opt/django/CAPgr..."   2 hours ago         Up 2 hours          443/tcp, 0.0.0.0:80->80/tcp, 8006/tcp   capgraph

在我的Vagrantfile中,我有:

  config.vm.network "forwarded_port", guest: 80, host: 9003

VMware settings window

VMware VM menu

Network adapter

1 个答案:

答案 0 :(得分:1)

您需要在VMware设置中添加另一个网络适配器,这应该与您的Wifi网络连接,因为您正在使用它。

这将允许您的VM在10.0.0.X系列中拥有另一个IP。该应用程序将在10.0.0.X:9003

上提供