Disk Cleanup after Deployment:
from 35% to now 75% free disc space
After the initial stable deployment, a common issue in modern container environments became visible: disk usage increased rapidly. Within a short time, the root partition reached ~75% utilization — not due to production data, but because of leftover artifacts from builds and testing.
Unused Docker images, build caches, stopped containers, and temporary files accumulated silently in the background.
The goal was clear: free disk space safely, without impacting running services or persistent data.
Analysis Before Action
Before deleting anything, the system state was analyzed:
df -h
du -sh /*
docker system df
docker images
docker ps -aThis step ensured a clear distinction between active resources and removable artifacts.
Controlled Cleanup
The cleanup was executed in three focused steps:
1. Remove unused Docker objects
docker system prune -f --filter "until=168h"- removes stopped containers
- removes unused networks
- removes dangling images
- keeps recent resources (last 7 days)
2. Remove build cache
docker builder prune --all --force- deletes BuildKit caches
- often the biggest hidden storage consumer
3. Clean temporary data
- clear
/tmp - remove Node/package caches
- reduce or delete old logs
Result
The effect was immediate:
- before: ~75% disk usage
- after: ~35% disk usage
A significant reduction achieved without downtime or risk.
Safety Considerations
The cleanup was designed to be safe:
- running containers were untouched
- Docker volumes were not removed
- active images remained intact
Sustainable Maintenance
To prevent future buildup, a weekly cron job was added:
docker system prune -f --filter "until=168h"This keeps the system clean automatically without manual intervention.
Best Practices
- monitor regularly with
docker system df - automate cleanup tasks
- optimize image builds (reduce layers, use cache wisely)
- keep logs and temp data under control
Conclusion
Disk cleanup is not a one-time fix — it's part of operating a stable container infrastructure.
In environments with frequent builds and deployments, unused artifacts grow quickly and invisibly. A structured cleanup approach ensures:
- stable disk usage
- better performance
- maintainable infrastructure
No downtime. No risk. Just reclaimed resources.