虛擬機器多了個網絡卡用ethtool -i檢視是veth驅動,是docker 惹得禍
阿新 • • 發佈:2020-10-12
當我通過docker run啟動任何容器時,我們得到一個新的veth interface.刪除容器後,應刪除與容器連結的veth介面.但是,有時它會失敗(然後容器啟動出錯):
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
我如何識別哪些介面與現有容器連結,以及如何刪除與已刪除的對手鍊接的額外介面?
這種方式不起作用(通過root):
ifconfig veth55d245e down
brctl delbr veth55d245e
can't delete bridge veth55d245e: Operation not permitted
現在由傳輸流量定義的額外介面(如果沒有活動,則是額外介面).
UPDATE
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介面數增加2,因為當Docker建立一個veth對時,該對的一端在容器名稱空間中被隔離,並且在主機中不可見.
>看起來你無法啟動容器:
Error response from daemon: Cannot start container ...
> Docker應該自動清理veth介面.
這些事實讓我懷疑你的環境中存在根本性的錯誤.您能否更新您的問題,詳細說明您正在使用的分發版,哪個核心版本以及哪個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介面:veth介面不是橋接器,所以當然你不能用brctl刪除它.
要刪除veth介面:
# ip link delete <ifname> <="" code="">
檢測“空閒”介面是一個棘手的問題,因為如果你只是看流量,你可能會意外刪除仍在使用但沒有看到太多活動的東西.
我認為你真正想要尋找的是veth介面,其對等體在全域性網路名稱空間中也是可見的.您可以使用these instructions找到veth介面的對等體,然後檢視該介面是否可見,然後刪除其中一個(刪除veth介面也將刪除其對等體)將是一件簡單的事情.