当我通过 docker run
启动任何容器时,我们会得到一个新的 veth interface .删除容器后,与容器链接的veth接口(interface)应该被删除。但是,有时它会失败(通常然后容器以错误启动):
root@hostname /home # ifconfig | grep veth | wc -l
53
root@hostname /home # docker run -d -P axibase/atsd -name axibase-atsd-
28381035d1ae2800dea51474c4dee9525f56c2347b1583f56131d8a23451a84e
Error response from daemon: Cannot start container 28381035d1ae2800dea51474c4dee9525f56c2347b1583f56131d8a23451a84e: iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 33359 -j DNAT --to-destination 172.17.2.136:8883 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)
root@hostname /home # ifconfig | grep veth | wc -l
55
root@hostname /home # docker rm -f 2838
2838
root@hostname /home # ifconfig | grep veth | wc -l
55
如何识别哪些接口(interface)与现有容器链接,以及如何删除与已删除的容器链接的额外接口(interface)?
这种方式不起作用(通过root):
ifconfig veth55d245e down
brctl delbr veth55d245e
can't delete bridge veth55d245e: Operation not permitted
现在由传输流量定义的额外接口(interface)(如果没有事件,则为额外接口(interface))。
更新
root@hostname ~ # uname -a
Linux hostname 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
root@hostname ~ # docker info
Containers: 10
Images: 273
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 502
Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.13.0-53-generic
Operating System: Ubuntu 14.04.2 LTS
CPUs: 8
Total Memory: 47.16 GiB
Name: hostname
ID: 3SQM:44OG:77HJ:GBAU:2OWZ:C5CN:UWDV:JHRZ:LM7L:FJUN:AGUQ:HFAL
WARNING: No swap limit support
root@hostname ~ # docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64
最佳答案
这里有三个问题:
启动单个容器不应将系统上的
veth
接口(interface)数量增加 2,因为当 Docker 创建veth
对时, pair 在容器命名空间中是隔离的,对宿主是不可见的。您似乎无法启动容器:
Error response from daemon: Cannot start container ...
Docker 应该会自动清理
veth
接口(interface)。
这些事实让我怀疑您的环境存在根本性的问题。您能否详细说明您使用的发行版、内核版本和 Docker 版本的详细信息?
How I can identify which interfaces are linked with existing containers, and how I can remove extra interface which was linked with removed contrainers?
关于手动删除 veth
接口(interface): veth
接口(interface)不是桥梁,所以你当然不能用 brctl
.
删除一个veth
接口(interface):
# ip link delete <ifname>
检测“空闲”接口(interface)是一个更棘手的问题,因为如果您只查看流量,您可能会意外删除仍在使用但没有看到太多事件的内容。
我认为您真正想要寻找的是 veth
接口(interface),其对等点 also 在全局网络命名空间中可见。您可以使用 these instructions 找到 veth
接口(interface)的对等点,然后查看该接口(interface)是否可见,然后删除一个或另一个(删除 veth
接口(interface)也将删除其对等点),这将是一件简单的事情。
关于linux - 如何识别孤立的 veth 接口(interface)以及如何删除它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31989426/