我正在尝试使用docker并想运行Ubiquiti video controller.我已经安装了Docker ToolBox并设法让容器在我的Yosemite主机上运行,并且可以通过访问docker返回的IP在同一台mac上访问它机器ip默认.但我想在网络上的其他机器上访问它,并最终在我的家用路由器上设置端口转发,以便我可以在我的家庭网络之外访问它.
正如boot2docker issue 160所建议的那样,使用VirtualBox GUI我能够添加桥接网络适配器,但重新启动VM docker-machine后无法再与VM连接. docker env默认挂起很长时间但最终返回一些环境变量以及消息超出最大重试次数(60).当我使用这些变量设置shell并尝试运行docker ps时,我收到错误:尝试连接时出错:获取https://10.0.2.15:2376/v1.20/containers/json:拨打tcp 10.0. 2.15:2376:网络无法访问.
我怀疑docker-machine对VM中的网络配置有一些假设,我正在弄乱它们.
docker-machine ssh ifconfig -a返回以下内容:
docker0 Link encap:Ethernet HWaddr 02:42:86:44:17:1E
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
dummy0 Link encap:Ethernet HWaddr 96:9F:AA:B8:BB:46
BROADCAST NOARP MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth0 Link encap:Ethernet HWaddr 08:00:27:37:2C:75
inet addr:192.168.1.142 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe37:2c75/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2996 errors:0 dropped:0 overruns:0 frame:0
TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:278781 (272.2 KiB) TX bytes:6824 (6.6 KiB)
Interrupt:17 Base address:0xd060
eth1 Link encap:Ethernet HWaddr 08:00:27:E8:38:7C
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee8:387c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:767 errors:0 dropped:0 overruns:0 frame:0
TX packets:495 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:122291 (119.4 KiB) TX bytes:116118 (113.3 KiB)
eth2 Link encap:Ethernet HWaddr 08:00:27:A4:CF:12
inet addr:192.168.99.100 Bcast:192.168.99.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fea4:cf12/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:430 errors:0 dropped:0 overruns:0 frame:0
TX packets:322 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:53351 (52.1 KiB) TX bytes:24000 (23.4 KiB)
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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth0似乎从我的路由器获得合理的DHCP地址.
我不确定这是否是正确的方法,或者我是否正在咆哮错误的树.如果我可以在虚拟机上运行桥接网络适配器,我不知道如何说服我的docker容器使用它.我试过在互联网上搜索高低.我找到了几十个网站,解释了如何使用docker-machine ip default而不是localhost来访问容器,但没有解释如何从其他主机访问.也许我需要提高我的谷歌搜索技巧.
最佳答案
原文链接:https://www.f2er.com/docker/436980.html