Docker 网络(四)——Docker 容器网络

ubuntu@ubuntu:~$ ip -d link show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 
2: eth0:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:4d:a8:3c brd ff:ff:ff:ff:ff:ff promiscuity 0 
3: eth1:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:eb:24:7f brd ff:ff:ff:ff:ff:ff promiscuity 0 
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default 
    link/ether 02:42:da:dc:5d:c4 brd ff:ff:ff:ff:ff:ff promiscuity 0 
    bridge 

ubuntu@ubuntu:~$ ip addr show docker0
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:da:dc:5d:c4 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:daff:fedc:5dc4/64 scope link 
       valid_lft forever preferred_lft forever

安装完成docker 后自动生成网络 docker0
我们运行一个容器

ubuntu@ubuntu:~$  docker run -it --rm ubuntu:14.04 bash
root@ff4d3aec1c19:/# ip addr show eth0
73: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.2/16 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:2/64 scope link 
       valid_lft forever preferred_lft forever

容器与主机间基于网桥 docker0通信。

ubuntu@ubuntu:~$ ip -d link show

4: docker0:  mtu 1500 qdisc noqueue state UP mode DEFAULT group default 
    link/ether 02:42:da:dc:5d:c4 brd ff:ff:ff:ff:ff:ff promiscuity 0 
    bridge 
78: veth6443df6:  mtu 1500 qdisc noqueue master docker0 state UP mode DEFAULT group default 
    link/ether de:b1:a2:fb:6b:1d brd ff:ff:ff:ff:ff:ff promiscuity 1 
    veth 

ubuntu@ubuntu:~$ brctl  show 
bridge name bridge id    STP enabled    interfaces
docker0  8000.0242dadc5dc4  no   veth6443df6

你可能感兴趣的:(Docker)