Keep you VPS with coolify Clean
How to keep a vps clean and ensure that old volumes are not eating up all the space.
How to Clean Up Unused Docker Volumes and Images on Your Coolify VPS
If your VPS is running low on disk space, Docker and Coolify might be the culprits. Over time, old containers, volumes, and images pile up and eat away at your storage. This guide will walk you through finding and removing these space hogs safely and easily.
What You'll Learn
How to find what's taking up space on your server
How to identify and remove unused Docker volumes
How to use an automated script to clean up Docker overlay files
How to perform a complete system cleanup
Part 1: Find What's Using Your Disk Space
Step 1: Install NCDU (Disk Usage Analyzer)
First, we need a tool that shows us exactly where our storage is going.
sudo apt install ncdu
What this does: Installs NCDU, a simple program that scans your disk and shows which folders are using the most space.
Step 2: Scan Your Entire System
Now let's scan the whole server to see where space is being used.
sudo ncdu /
What this does: Starts scanning from the root directory (/) and builds a visual map of your disk usage. This might take a few minutes depending on how much data you have.
Step 3: Navigate and Explore
Once the scan finishes, you'll see a list of directories with their sizes.
How to use it:
Use arrow keys to move up and down
Press Enter to dive into a folder
Press d to delete a file (be careful!)
Press q to quit
Where to look: The biggest storage directories are usually:
/var/lib/docker/volumes- Old database and app data/var/lib/docker/overlay2- Leftover container files
Step 4: Identify Problem Files
Navigate into these Docker directories and look for:
Volumes from deleted apps
Old database folders (like ClickHouse, PostgreSQL, etc.)
Containers you're no longer using
Example: In my case, I found old ClickHouse volumes taking up 15GB that should have been deleted when I removed the app.
Step 5: Remove Specific Volumes Manually
If you found a volume you want to delete, use this command:
docker volume rm volume_name_here
Example:
docker volume rm v8swk8w04k048wc80w8kw8gk_langfuse-clickhouse-logs
What this does: Permanently deletes the specified Docker volume. Make sure you don't need the data before running this!
Part 2: Use the Automated Docker Cleanup Script
Manual cleanup is good, but there's a faster way to clean up Docker's hidden overlay files.
Step 1: Download the Cleanup Script
curl -L -o docker-pruner.sh https://gist.githubusercontent.com/fayak/3a438426a906d9b85b68bc38ead6d5bb/raw
What this does: Downloads a specialized script that finds and removes unused Docker overlay directories (leftover files from old containers).
Step 2: Make the Script Runnable
chmod +x docker-pruner.sh
What this does: Gives the script permission to run on your system.
Step 3: See What Will Be Deleted (Safe Preview)
Before deleting anything, let's see what the script found:
sudo ./docker-pruner.sh list
What this does: Shows you all the unused overlay directories that are safe to delete. No changes are made yet—this is just a preview.
Step 4: Test Safely with Markers (Recommended)
This optional step adds an extra safety check:
sudo ./docker-pruner.sh marker
What this does: Places a temporary marker file in each unused directory to track them.
Then check if any running containers are using those directories:
sudo ./docker-pruner.sh check
What this does: Verifies that no active containers or images depend on those directories. If you see "Problem detected!", don't proceed—restart the affected containers first.
Step 5: Run the Cleanup
If everything looks good, it's time to clean up:
sudo ./docker-pruner.sh clear
What this does: Deletes all the unused overlay directories, freeing up disk space immediately.
Step 6: Complete System Cleanup
Finish with Docker's built-in cleanup commands:
sudo docker system prune -af --volumes
What this does: Removes:
All stopped containers
All unused networks
All dangling images
All unused volumes
Then clear the build cache (if you build Docker images):
sudo docker builder prune -f
What this does: Removes old build cache files that Docker keeps when building images.
Final Tips
✅ Check your disk space before and after with df -h to see how much you freed up
✅ Run cleanup regularly - Set a monthly reminder to prevent storage issues
✅ Be careful with volumes - Always verify you don't need the data before deleting volumes
✅ Back up important data - Before any major cleanup, back up critical databases and files
⚠️ Never delete volumes from running apps - Always stop or remove apps through Coolify first
Quick Reference Commands
# Check disk space
df -h
# Scan disk usage
sudo ncdu /
# Remove specific volume
docker volume rm <volume_name>
# List all volumes
docker volume ls
# Complete cleanup (use with caution)
sudo docker system prune -af --volumes
Related Posts
Minimal self hosted E2E Setup with Playwright and Allure (Docker)
his minimal stack shows how to do that with Playwright for tests, Allure for reports, Cronicle for scheduling, and optional self‑hosting via Coolify
How to Fix Docker Orphaned Layers and Reclaim Lost Disk Space
Learn how to identify and fix Docker's with Coolify orphaned layer problem that wastes disk space. Step-by-step guide to safely reset Docker data directory and reclaim gigabytes of storage on your VPS server.
How to Manage SQLite Databases on a VPS ( with Coolify )
The Problem Keeping a SQLite database consistent between a Docker‑based VPS and local development requires a shared persistent volume, correct path...
Let's connect !!
Get in touch if you want updates, examples, and insights on how AI agents, Langchain and more are evolving and where they’re going next.