Know the used storage of each single container

I have about 50 containers on one btrfs storage pool (lxd with snap and default.img)

How can I know the used storage of each single container?

The lxc info <instance> command will show root disk usage.
Keep in mind on BTRFS LXD uses snapshots of the source image so it may be smaller than you are expecting.

Thanks for the reply.

This solution returns a somewhat “wrong” or rather not real parameter.

I can get the correct parameter with the following command executed inside the container:

  • du -hs -m --exclude=/proc --exclude=/sys --exclude=/dev /

However, this method uses a lot of resources, and if we wanted to calculate the amount of storage used every “x” minutes, I would have an unjustified consumption of the entire server on 50 containers.

Do you have any recommendations?

It does not, or I am wrong?

lxc info proxy
Name: proxy
Status: RUNNING
Type: container
Architecture: x86_64
PID: 2394
Created: 2023/12/02 13:01 CET
Last Used: 2023/12/08 16:21 CET

Resources:
Processes: 17
CPU usage:
CPU usage (in seconds): 4
Memory usage:
Memory (current): 24.85MiB
Network usage:
eth0:
Type: broadcast
State: UP
Host interface: veth8f829381
MAC address: 00:16:3e:49:e1:2d
MTU: 1500
Bytes received: 3.86MB
Bytes sent: 25.30kB
Packets received: 430
Packets sent: 286
IP addresses:
inet: 192.168.0.12/28 (global)
inet6: fe80::216:3eff:fe49:e12d/64 (link)
lo:
Type: loopback
State: UP
MTU: 65536
Bytes received: 3.94MB
Bytes sent: 3.94MB
Packets received: 559
Packets sent: 559
IP addresses:
inet: 127.0.0.1/8 (local)
inet6: ::1/128 (local)