看到docker安装启动之后出现的“网卡” docker0
比较好奇,想着怎么可以把它删除。
$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:34:6f:00 brd ff:ff:ff:ff:ff:ff
inet 172.28.32.49/24 brd 172.28.32.255 scope global dynamic eth0
valid_lft 3151251593sec preferred_lft 3151251593sec
inet6 fe80::f816:3eff:fe34:6f00/64 scope link
valid_lft forever preferred_lft forever
3: docker0: mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:89:af:c2:05 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
$ service docker stop
docker0 仍然存在。
尝试删除 docker0
$ brctl delbr docker0
bridge docker0 is still up; can't delete it
要想让 docker0 消失, 可以把该网卡停掉
$ ifconfig docker0 down
$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:34:6f:00 brd ff:ff:ff:ff:ff:ff
inet 172.28.32.49/24 brd 172.28.32.255 scope global dynamic eth0
valid_lft 3151224228sec preferred_lft 3151224228sec
inet6 fe80::f816:3eff:fe34:6f00/64 scope link
valid_lft forever preferred_lft forever
3: docker0: mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:89:af:c2:05 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
$ brctl delbr docker0
查看ifconfig, 发现 docker0
消失了。
$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:34:6f:00 brd ff:ff:ff:ff:ff:ff
inet 172.28.32.49/24 brd 172.28.32.255 scope global dynamic eth0
valid_lft 3151224188sec preferred_lft 3151224188sec
inet6 fe80::f816:3eff:fe34:6f00/64 scope link
valid_lft forever preferred_lft forever
$ service docker restart
Redirecting to /bin/systemctl restart docker.service
$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:34:6f:00 brd ff:ff:ff:ff:ff:ff
inet 172.28.32.49/24 brd 172.28.32.255 scope global dynamic eth0
valid_lft 3151224029sec preferred_lft 3151224029sec
inet6 fe80::f816:3eff:fe34:6f00/64 scope link
valid_lft forever preferred_lft forever
4: docker0: mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:02:5d:b4:26 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
$ ifconfig docker0 up
$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:34:6f:00 brd ff:ff:ff:ff:ff:ff
inet 172.28.32.49/24 brd 172.28.32.255 scope global dynamic eth0
valid_lft 3151224003sec preferred_lft 3151224003sec
inet6 fe80::f816:3eff:fe34:6f00/64 scope link
valid_lft forever preferred_lft forever
4: docker0: mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:02:5d:b4:26 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever
启动一个 ubuntu
的镜像:
$ docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
Trying to pull repository docker.io/library/ubuntu ...
latest: Pulling from docker.io/library/ubuntu
d5c6f90da05d: Pull complete
1300883d87d5: Pull complete
c220aa3cfc1b: Pull complete
2e9398f099dc: Pull complete
dc27a084064f: Pull complete
Digest: sha256:47716ab73252837a8bae20dcedfe86087fa71bb7d3c339160731b3d0aacb5d7b
查看docker的进程:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b9feedd7651 ubuntu "bash" 3 minutes ago Up 3 minutes
查看 ipconfig:
$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
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: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:34:6f:00 brd ff:ff:ff:ff:ff:ff
inet 172.28.32.49/24 brd 172.28.32.255 scope global dynamic eth0
valid_lft 3151223622sec preferred_lft 3151223622sec
inet6 fe80::f816:3eff:fe34:6f00/64 scope link
valid_lft forever preferred_lft forever
4: docker0: mtu 1500 qdisc noqueue state UP
link/ether 02:42:02:5d:b4:26 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:2ff:fe5d:b426/64 scope link
valid_lft forever preferred_lft forever
10: veth655cca0@if9: mtu 1500 qdisc noqueue master docker0 state UP
link/ether ae:1b:6d:ab:94:5b brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::ac1b:6dff:feab:945b/64 scope link
valid_lft forever preferred_lft forever
扩展阅读:
===========
```
$ brctl --help
Usage: brctl [commands]
commands:
addbr add bridge
delbr delete bridge
addif add interface to bridge
delif delete interface from bridge
hairpin {on|off} turn hairpin on/off
setageing