docker0网络模型step by step
将docker的ns软链到linux ns
$ ln -s /var/run/docker/netns /var/run/netns
查看ns,无
$ ip netns
$
启动b1
$ docker run -itd --name b1 busybox
af051e24e639508da0f2824b2da001ca54f61fced0d73fdbe5604331ef804489
查看ns,有1个了
$ ip netns
2ea8e31a85ef (id: 0)
删除b1
$ docker rm -fv b1
b1
即刻查看ns-报错
$ ip netns
RTNETLINK answers: Invalid argument
RTNETLINK answers: Invalid argument
2ea8e31a85ef
过了2-5min查看ns-无(docker延迟处理ns)
$ ip netns
$
批量观察
$ docker run -itd --name b1 busybox
184f7ce462677e14323517a66615051269d26cf13a17b3e61dc8920eccae3731
$ ip netns
147d24ac5383 (id: 0)
$ docker run -itd --name b2 busybox
6fe77ef5416e2b3b5f781df454b2c854e24c003eac8e90f0641dd14f1f8aafce
$ ip netns
13da34d6e0d8 (id: 1)
147d24ac5383 (id: 0)
$ docker run -itd --name b3 busybox
4db189e89c550e8549300e2284942135dce0126a42e5166f8c62a23060320077
$ ip netns
eda4e0f95513 (id: 2)
13da34d6e0d8 (id: 1)
147d24ac5383 (id: 0)
$ docker run -itd --name b4 busybox
94f88f61efadd113eca79d21c783a01e5c3a2aa8ee3ff0608fa38d19afc5fab9
$ ip netns
d333e65e89d3 (id: 3)
eda4e0f95513 (id: 2)
13da34d6e0d8 (id: 1)
147d24ac5383 (id: 0)
docker0网络模型小结
参考: http://blog.daocloud.io/docker-bridge/
可见每容器一个namespace
ns1 容器b1---veth1--> docker0
ns2 容器b2---veth2-->
ns3 容器b3---veth3-->
ns4 容器b4---veth4-->