主机网络没有包含 docker 主机网络模型接口 IP 的 IP 段
Host network do not have a IP segment who contains the docker host network model's interface IP
我得到了docker网络快照的四种模型类型:
主机模型(开放容器)附加到主机的逻辑主机接口和环回接口。
在我的例子中,我创建了宿主模型容器:
$ docker run --name container-bridge --network=host -it --rm busybox:latest
并且在容器中它有 10 个虚拟接口。
/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 02:50:00:00:00:01 brd ff:ff:ff:ff:ff:ff
inet 192.168.65.3/24 brd 192.168.65.255 scope global deprecated dynamic noprefixroute eth0
valid_lft 1415sec preferred_lft 0sec
inet6 fe80::50:ff:fe00:1/64 scope link
valid_lft forever preferred_lft forever
3: tunl0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
link/ipip 0.0.0.0 brd 0.0.0.0
4: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop qlen 1000
link/tunnel6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
5: services1@if6: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
link/ether c2:db:47:39:c7:fc brd ff:ff:ff:ff:ff:ff
inet 192.168.65.4 peer 192.168.65.5/32 scope global services1
valid_lft forever preferred_lft forever
inet6 fe80::c0db:47ff:fe39:c7fc/64 scope link
valid_lft forever preferred_lft forever
7: br-b7cc12043647: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue
link/ether 02:42:30:d7:06:a7 brd ff:ff:ff:ff:ff:ff
inet 192.168.49.1/24 brd 192.168.49.255 scope global br-b7cc12043647
valid_lft forever preferred_lft forever
inet6 fe80::42:30ff:fed7:6a7/64 scope link
valid_lft forever preferred_lft forever
8: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
link/ether 02:42:9e:26:2d:f9 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:9eff:fe26:2df9/64 scope link
valid_lft forever preferred_lft forever
10: veth2fba778@if9: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue master br-b7cc12043647
link/ether 52:64:9d:7f:d1:01 brd ff:ff:ff:ff:ff:ff
inet6 fe80::5064:9dff:fe7f:d101/64 scope link
valid_lft forever preferred_lft forever
主界面是 eth0
用于连接主机(我的 macos),主机的 IP 地址为 192.168.65.3/24
但是在我的 macOS 中,我没有在网段 192.168.65.0/24
.
下找到 IP 地址
$ ifconfig -a | grep 192.168.65
参见 Use host networking,它清楚地提到 --net=host
不适用于 macos:
The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.
所以,容器中的网络肯定与您macos中的网络不同。
我得到了docker网络快照的四种模型类型:
主机模型(开放容器)附加到主机的逻辑主机接口和环回接口。
在我的例子中,我创建了宿主模型容器:
$ docker run --name container-bridge --network=host -it --rm busybox:latest
并且在容器中它有 10 个虚拟接口。
/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 02:50:00:00:00:01 brd ff:ff:ff:ff:ff:ff
inet 192.168.65.3/24 brd 192.168.65.255 scope global deprecated dynamic noprefixroute eth0
valid_lft 1415sec preferred_lft 0sec
inet6 fe80::50:ff:fe00:1/64 scope link
valid_lft forever preferred_lft forever
3: tunl0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
link/ipip 0.0.0.0 brd 0.0.0.0
4: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop qlen 1000
link/tunnel6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
5: services1@if6: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue
link/ether c2:db:47:39:c7:fc brd ff:ff:ff:ff:ff:ff
inet 192.168.65.4 peer 192.168.65.5/32 scope global services1
valid_lft forever preferred_lft forever
inet6 fe80::c0db:47ff:fe39:c7fc/64 scope link
valid_lft forever preferred_lft forever
7: br-b7cc12043647: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue
link/ether 02:42:30:d7:06:a7 brd ff:ff:ff:ff:ff:ff
inet 192.168.49.1/24 brd 192.168.49.255 scope global br-b7cc12043647
valid_lft forever preferred_lft forever
inet6 fe80::42:30ff:fed7:6a7/64 scope link
valid_lft forever preferred_lft forever
8: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
link/ether 02:42:9e:26:2d:f9 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:9eff:fe26:2df9/64 scope link
valid_lft forever preferred_lft forever
10: veth2fba778@if9: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue master br-b7cc12043647
link/ether 52:64:9d:7f:d1:01 brd ff:ff:ff:ff:ff:ff
inet6 fe80::5064:9dff:fe7f:d101/64 scope link
valid_lft forever preferred_lft forever
主界面是 eth0
用于连接主机(我的 macos),主机的 IP 地址为 192.168.65.3/24
但是在我的 macOS 中,我没有在网段 192.168.65.0/24
.
$ ifconfig -a | grep 192.168.65
参见 Use host networking,它清楚地提到 --net=host
不适用于 macos:
The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.
所以,容器中的网络肯定与您macos中的网络不同。