docker - docker0网络
docker0 网桥通信
查看容器虚拟网卡
docker 每创建一个容器,都会创建一个虚拟网卡
xiao@z:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 30:c9:ab:8b:33:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.17/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp1s0
valid_lft 70709sec preferred_lft 70709sec
inet6 240e:388:a900:2427:de0a:5d3d:12a7:f790/64 scope global temporary dynamic
valid_lft 259156sec preferred_lft 70335sec
inet6 240e:388:a900:2427:af7d:879e:6e74:600f/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 259156sec preferred_lft 172756sec
inet6 fe80::9ccf:bdd:16e8:f4f/64 scope link noprefixroute
valid_lft forever preferred_lft forever
# 容器网卡
19: vethb183796@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-af3afa6861bd
state UP group default
link/ether 6e:7b:50:81:a2:78 brd ff:ff:ff:ff:ff:ff link-netnsid 3
inet6 fe80::6c7b:50ff:fe81:a278/64 scope link
进入容器查看网卡
xiao@z:~$ docker exec -it registry /bin/sh
/ # ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
## 虚拟网卡
18: eth0@if19: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether 02:42:ac:17:00:02 brd ff:ff:ff:ff:ff:ff
inet 172.23.0.2/16 brd 172.23.255.255 scope global eth0
valid_lft forever preferred_lft forever
可以发现,容器内的虚拟网卡和宿主机上的虚拟网卡是成对出现的