Docker Cleanup Workflow Saves 40GB Monthly
The docker-cleanup ClawFlows workflow reclaims disk space by pruning unused Docker images, containers, and volumes — safely and on a schedule.
Every developer with Docker installed eventually discovers the disk-space problem. Docker images pile up. Stopped containers linger. Dangling volumes hide in obscure paths. Build caches never get cleaned. Before you know it, your 1TB SSD has 200GB of Docker detritus and you're wondering why your machine feels slow.
The classic fix is running docker system prune periodically. This works, but it's aggressive, it's destructive, and you have to remember to do it. Most developers run it approximately never.
The docker-cleanup workflow from ClawFlows is the civilized alternative. It cleans up safely, it knows what to preserve, and — critically — it runs on a schedule so you never have to remember.
Key Takeaways
- docker-cleanup is a ClawFlows workflow in the Dev Tools category that reclaims Docker disk space.
- It removes unused images, stopped containers, and dangling volumes with configurable safety rules.
- It preserves images you've used recently so it doesn't break active workflows.
- It runs on a schedule via cron or launchd so cleanup happens automatically.
- On a busy dev machine, it typically reclaims 20-60GB per month.
The Docker Disk Problem
Docker is designed to be disk-hungry. Every pull adds an image. Every build adds layers. Every run that isn't explicitly removed leaves a stopped container behind. Every volume that gets detached from a container lingers. None of this is accidental — Docker's immutability model requires keeping old stuff around until you explicitly say otherwise.
The consequence is that dev machines accumulate Docker crud at a rate of 20-60GB per month depending on workload. Over a year, that's enough to fill a midsize SSD.
The solution isn't to stop using Docker. It's to schedule regular, safe cleanup.
What the Workflow Does
When you invoke docker-cleanup, the workflow:
- Reports current Docker disk usage — total, by category
- Identifies candidates for removal:
- Stopped containers older than a threshold
- Images not used by any container and older than a threshold
- Dangling volumes
- Build cache older than a threshold
- Excludes protected items based on your configuration
- Shows you the plan before executing
- Prunes the identified items
- Reports reclaimed space after cleanup
Default thresholds are conservative — 7 days for stopped containers, 14 days for unused images. You can tune them based on your workflow.
How Is It Different From docker system prune -af?
docker system prune -af is a nuke. It removes everything that isn't actively running, including images you might need tomorrow. That's fine if you're sure you don't need any of it, but most developers can't be sure.
docker-cleanup is surgical. It respects age thresholds, honors your exclusion list, and shows you the plan before executing. The result is that you can run it safely on an active dev machine without fear of breaking tomorrow's work.
Safety Rules
The workflow supports an exclusion list. Common exclusions:
- Images from registries you use frequently (even if not currently running)
- Named volumes that contain important data
- Specific container names (e.g., your dev database container)
- Images tagged with specific labels
You configure these once and the workflow respects them on every run. Misconfigurations are recoverable — Docker keeps images in its registry cache, so re-pulling is usually fast.
The Schedule That Works
My schedule for docker-cleanup:
- Weekly on Sunday night — conservative pass, default thresholds
- Monthly full sweep — aggressive thresholds (3 days), run after I've committed all WIP
The weekly pass typically reclaims 5-15GB. The monthly full sweep often reclaims 30-60GB. Between them, Docker never accumulates more than about 100GB of disk use on my machine.
Before running it on a schedule, I was periodically losing entire evenings to "why is my disk full" crises. After, the problem just stopped existing.
Pairing With Other Dev Workflows
docker-cleanup is part of a broader dev-hygiene routine. I run it alongside:
- clean-branches — local Git branch cleanup
- reset-dev-env — full environment reset when things are haunted (covered in 12 Dev Tool Workflows Every Engineer Needs)
- update-deps — monthly dependency update and test pass
- check-dependencies — security audit (profiled in Check-Dependencies: NPM Security Automation)
Running all four quarterly takes about 20 minutes of attention and keeps the dev environment in genuinely good shape.
Customization Examples
How people have customized docker-cleanup:
- A ML engineer added exclusion for large model-serving images (several GB each) that they use daily
- A DevOps engineer added reporting to Slack with reclaimed space after each run
- A consultant added per-client image handling — cleanup rules differ by which client's work is active
- A minimalist reduced thresholds to 1 day for maximum reclamation
- A cautious user added a dry-run mode that reports but doesn't delete
We cover authoring changes in Writing Your First Custom ClawFlow.
What About CI Runners?
docker-cleanup works on CI runners too. Many teams run it as a scheduled job on their self-hosted runners to prevent disk issues. The schedule can be more aggressive on CI than on dev machines because CI environments are ephemeral by design.
FAQ
Will it delete something I need?
Not if you configure the exclusion list correctly. The default thresholds (7 days for containers, 14 for images) are conservative, and you can review the plan before it executes.
Does it work on Docker Desktop?
Yes, on macOS and Windows. Docker Desktop's VM disk is included in the cleanup — reclaiming space inside the VM automatically reduces the VM file size over time.
What about Docker volumes with important data?
Name your important volumes and add them to the exclusion list. Unnamed (anonymous) volumes are typically safe to prune, but the workflow lets you exclude those too if you want extra caution.
Can I run it on a remote Docker host?
Yes. The workflow connects to whatever Docker daemon your CLI is configured to use. Many users run it against their home-lab Docker hosts.
How long does a typical cleanup take?
A few seconds for the analysis, a few more for the actual pruning. On a machine with hundreds of images to remove, it can take a minute or two. Large volume deletions can take longer.
Reclaim Your Disk This Weekend
If your dev machine has a "Docker problem," docker-cleanup is the cheapest fix. Install ClawFlows (see How to Install ClawFlows in One Command), configure your exclusion list, schedule it weekly, and reclaim 40GB this month. Next month, too. And every month after.
Explore all 113 workflows at aiskill.market/workflows or submit your own.