Have you ever encountered the dreaded situation where your Docker daemon stops working because your disk is full? It’s a common problem that can bring your containerized applications to a halt. Today, we’re introducing a script that makes recovering from this situation much easier and safer.
The Problem
When Docker fills up your disk space, it creates a cascade of issues:
- The Docker daemon stops working
- You can’t remove containers or images
- Your applications become unavailable
- You can’t even use Docker commands to clean up
It’s a classic catch-22: you need Docker running to clean up Docker, but Docker won’t run because there’s no space!
The Solution
We’ve created the Big Bear Debian Docker Disk Recovery Tool - a script that safely guides you through the process of recovering disk space and getting Docker back online. Here’s what makes it special:
Safety First Approach
- Never deletes your important container data
- Preserves all your Docker images
- Keeps your container configurations intact
- Interactive process - you’re in control
Step-by-Step Recovery
The script follows a careful, systematic approach:
-
Initial System Cleanup
- Clears system journal logs
- Cleans package manager cache
- Truncates Docker container logs
- Offers individual container log cleanup
-
Docker Cleanup (once running)
- Removes stopped containers
- Cleans unused images
- Removes dangling volumes
- Cleans up unused networks
-
Additional Options
- Option to reinstall Docker
- Docker Compose installation
- Comprehensive cleanup statistics
How to Use the Script
-
First, make sure you’re running as root or with sudo privileges.
-
Run this one-line command to download and execute the script:
sudo bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/debian-docker-disk-recovery/run.sh)"
-
Follow the interactive prompts:
- The script will show current disk usage
- Each cleanup step requires your confirmation
- You’ll see the impact of each action
- Clear statistics show what was cleaned up
Real-World Example
Let’s say your server has run out of space. Here’s how the script helps:
-
Initial Assessment
Filesystem Size Used Avail Use% Mounted on /dev/sda1 30G 30G 0G 100% /
-
Cleanup Process
- Clearing logs might free up 500MB
- Cleaning package cache: another 200MB
- Truncating Docker logs: 1GB
- Docker running again!
-
Further Optimization
- Remove unused images: 5GB
- Clean old volumes: 2GB
- Final result: 8.7GB freed!
Best Practices
To prevent this issue in the future:
-
Regular Maintenance
- Schedule regular Docker cleanup
- Monitor disk usage
- Set up alerts for low disk space
-
Proactive Management
- Use Docker’s built-in prune commands
- Implement log rotation
- Consider using volume drivers for data
Conclusion
The Big Bear Debian Docker Disk Recovery Tool turns a stressful situation into a manageable process. It’s designed to be safe, interactive, and effective, helping you get your Docker environment back online quickly.
Support and Community
- Visit our community: BigBearTechWorld Community
- Support us: Ko-fi
- More scripts: GitHub
Have you encountered Docker disk space issues? How do you handle them? Share your experiences in the comments below!