How to find the size of a lxc container
In order to determine the size of a LXC container, first run lxc storage list to list your storage pools:
lxc_storage_list.sh
uli@myserver:~$ lxc storage list
+---------+-------------+--------+------------------------------------+---------+
| NAME | DESCRIPTION | DRIVER | SOURCE | USED BY |
+---------+-------------+--------+------------------------------------+---------+
| default | | dir | /var/lib/lxd/storage-pools/default | 2 |
+---------+-------------+--------+------------------------------------+---------+If the driver is not dir, you are using a COW-type storage backend. Using this technology it is not possible to easily determine the storage size of a container. The following instructions apply only for the dir driver.
Now open a root shell and cd to the directory listed in the SOURCE column and cd to its containers subdirectory:
cd_to_containers.sh
root@myserver ~ # cd /var/lib/lxd/storage-pools/default
root@myserver /var/lib/lxd/storage-pools/default # cd containers/
root@myserver /var/lib/lxd/storage-pools/default/containers #This directory contains the storage directory for all containers. Run du -sh * in order to find the size of each container:
du_containers.sh
root@myserver /var/lib/lxd/storage-pools/default/containers # du -sh *
2.0G my-containerIn this example, the container my-container occupies 2.0 Gibibytes of disk space.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow