apple / apple/containerization
[Request]: Storage - Automatically reclaim unused disk space from containers with minimal user interaction
- Dominant language
- Swift
- Stars
- 8.9k
- Forks
- 359
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 13
Description
### 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 ` to launch a temporary VM, mount the image, run `fstrim` and shut down.
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Contributor guide
Assessment
This issue has not been assessed yet.