如何在Mac OS X上将USB无线接口连接到Docker容器?

时间:2017-04-08 10:06:55

标签: linux macos docker containers network-interface

我有一个Linux Docker容器,需要无线接口才能工作。在Linux上(在Linux主机上运行)我没有问题。

使用参数--privileged--net=host运行Docker容器我可以访问主机无线接口,我可以毫无问题地管理它们。问题是当我在Mac OS X主机上运行相同的Linux Docker容器时。我看不到Docker容器内的无线接口。

这是Mac OS X v10.12(Sierra)主机上ifconfig的输出:

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
    inet 127.0.0.1 netmask 0xff000000
    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
    nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=b<RXCSUM,TXCSUM,VLAN_HWTAGGING>
    ether 00:0c:29:fe:78:07
    inet6 fe80::8ff:62ac:e141:5aa9%en0 prefixlen 64 secured scopeid 0x4
    inet 192.168.0.153 netmask 0xffffff00 broadcast 192.168.0.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect (1000baseT <full-duplex>)
    status: active
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 00:c0:ca:5a:00:f2
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect (<unknown type>)
    status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
    inet6 fe80::7a12:53b9:61c3:3c7%utun0 prefixlen 64 scopeid 0x6
    nd6 options=201<PERFORMNUD,DAD>

“en1”接口是无线USB设备。现在容器内的ifconfig输出使用描述的参数运行:

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 0.0.0.0
        ether 02:42:67:b5:aa:36  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.65.2  netmask 255.255.255.248  broadcast 192.168.65.7
        inet6 fe80::b564:23a5:1418:8f2a  prefixlen 64  scopeid 0x20<link>
        ether c0:ff:ee:c0:ff:ee  txqueuelen 1000  (Ethernet)
        RX packets 22  bytes 2418 (2.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33  bytes 3100 (3.0 KiB)
        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
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 3  bytes 54 (54.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 54 (54.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我猜容器的eth0被“映射”到en0接口并且正在工作,我在容器内部可以访问Internet。但是,为什么我没有看到en1映射到容器上的任何设备?

如何在Mac OS X上实现此目的?如果我从命令行中删除--net=host以启动Docker,则接口docker0在容器内消失...是不同的,但无论如何都不会出现无线接口。

0 个答案:

没有答案