Feature or enhancement request details
Container disk images currently grow over time but never shrink. As containers create and delete data, freed blocks inside their filesystems are not automatically released to the host, leading to permanently increasing disk utilization. This results in wasted space for long-lived containers and unnecessary manual intervention to recover capacity.
To address this, we should automatically reclaim freed blocks from container filesystems using fstrim with minimal user interaction, this way users do not need to manually intervene or recreate containers to reclaim disk space.
Some implementation options:
- Online fstrim: Run
fstrim while the container is active to release deallocated blocks to the host.
- Periodic cleanup: Execute
fstrim periodically within vminitd for automated cleanup.
- Continuous discard: Mount filesystems with the
discard option for continuous trimming.
- Manual offline shrink: Allow users to run
container shrink <id> to launch a temporary VM, mount the image, run fstrim and shut down.
Code of Conduct