[lxc-users] Remaining virtual ethernet interfaces (veth) after container has been deleted

Mike Wright nobody at nospam.hostisimo.com
Thu Mar 26 18:36:26 UTC 2020


On 3/26/20 8:14 AM, Sebert, Holger.ext wrote:
> Hi,
> 
> we use LXD containers on our CI-build nodes. For each build a container is
> created and deleted afterwards. So, container creation and deletion happens
> quite often.
> 
> Here is the problem: After some time, many virtual ethernet interfaces (veth*)
> accumulate, they look like this:
> 
> vethY59JK1 Link encap:Ethernet  HWaddr fe:12:cc:54:20:70
> 		  inet6 addr: fe80::fc12:ccff:fe54:2070/64 Scope:Link
> 		  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
> 		  RX packets:60 errors:0 dropped:0 overruns:0 frame:0
> 		  TX packets:14095 errors:0 dropped:0 overruns:0 carrier:0
> 		  collisions:0 txqueuelen:1000
> 		  RX bytes:6735 (6.7 KB)  TX bytes:2417738 (2.4 MB)
> 
> ...
> 
> vethYCP720 Link encap:Ethernet  HWaddr fe:6c:d0:78:b0:63
> 		  inet6 addr: fe80::fc6c:d0ff:fe78:b063/64 Scope:Link
> 		  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
> 		  RX packets:61 errors:0 dropped:0 overruns:0 frame:0
> 		  TX packets:14075 errors:0 dropped:0 overruns:0 carrier:0
> 		  collisions:0 txqueuelen:1000
> 		  RX bytes:6653 (6.6 KB)  TX bytes:2414750 (2.4 MB)
> 
> 
> These interfaces are not connected to any running container and cannot be
> removed. It seems to me that they are somehow leftovers from previous
> containers which don't exist anymore.

Hi Holger,

A technique I use is to give each container's interfaces unique names on 
the host, usually the same name as the container itself.  If there is 
more than one interface I add a digit.

e.g. container "zorro" has a profile named "zorro".  Here is a snip from 
"zorro's" yaml profile:

devices:
   eth0:
     host_name: zorro  <--- will show up on the host

An interface cannot be removed while it is up.

ip link set dev zorro down  (short way: ip l s zorro down)
ip link del dev zorro       (short way: ip l d zorro)

A deleted interface is automagically removed from any bridge it's on.

Mike Wright


More information about the lxc-users mailing list