Interactive Docker resource cleanup scripts with beautiful UI for macOS systems. These scripts help you safely clean up unused Docker resources including dangling images, stopped containers, unused volumes, and build cache.
| Script | Language | File | Purpose |
|---|---|---|---|
| π©πͺ German | German | docker-cleaner-de.sh |
German version of the interactive Docker cleaner |
| π¬π§ English | English | docker-cleaner-en.sh |
English version of the interactive Docker cleaner |
- macOS (designed for macOS Terminal)
- Docker Desktop installed and running
- bash shell
# Make scripts executable (first time only)
chmod +x docker-cleaner.sh
chmod +x docker-cleaner-en.sh
# Run German version
./docker-cleaner.sh
# Run English version
./docker-cleaner-en.sh
# Run with test mode (no actual deletions)
./docker-cleaner.sh --test
./docker-cleaner-en.sh --test
# Show help
./docker-cleaner.sh --help
./docker-cleaner-en.sh --helpRemoves Docker images with <none> repository and tag names that are created during build processes.
# Example: Find and remove dangling images
./docker-cleaner.sh
# Select option [1] - Delete dangling imagesRemoves stopped/unused containers to free up system resources.
Safely removes unused volumes (with warnings about potential data loss).
Clears Docker build cache to reclaim significant disk space.
Shows comprehensive Docker system statistics and resource usage.
Preview what would be deleted without actually removing anything.
- Colored ASCII menus with Unicode box-drawing characters
- Emoji indicators for different operations and states
- Interactive dialogs with confirmation prompts
- Progress indicators and status messages
- Modern color scheme optimized for macOS Terminal
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π³ DOCKER CLEANER v1.0.0 β
β Interactive Resource Cleanup β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Status: π’ Running | Storage: 6GB
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π§Ή Docker Resource Cleaner - Main Menu β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β [1] ποΈ Delete dangling images (<none> images) β
β [2] π³ Cleanup unused containers β
β [3] πΎ Cleanup unused volumes β
β [4] π¨ Clear build cache β
β [5] π Show detailed analysis β
β [6] π Full cleanup (all above) β
β [7] βοΈ Advanced options β
β β
β [0] πͺ Exit β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Every destructive operation requires explicit confirmation with clear warnings about potential consequences.
Run scripts in test mode to see what would be deleted without actually removing anything:
./docker-cleaner.sh --testAll operations show detailed previews of what will be deleted, including:
- List of affected resources
- Amount of disk space to be reclaimed
- Number of items to be removed
Special warnings for volume deletions due to potential data loss:
β οΈ Found: 3 unused volumes
WARNING: Deleting volumes can cause data loss!
| Option | Description | Example |
|---|---|---|
--help, -h |
Show help information | ./docker-cleaner.sh --help |
--test |
Activate test mode (no deletions) | ./docker-cleaner.sh --test |
--version |
Show script version | ./docker-cleaner.sh --version |
- Operating System: macOS (tested on macOS Monterey and later)
- Docker: Docker Desktop for Mac
- Shell: bash 3.2+ (default macOS bash)
- Terminal: Supports ANSI colors and Unicode characters
docker images --filter "dangling=true"docker ps -a --filter "status=exited"docker volume ls --filter "dangling=true"docker system dfdocker rmi,docker rm,docker volume prunedocker builder prune --all --force
docker-cleaner.sh
βββ UI/Helper Functions (colors, menus, dialogs)
βββ Docker Analysis Functions (counting, sizing)
βββ Cleanup Functions (images, containers, volumes, cache)
βββ Menu Functions (main menu, advanced menu)
βββ Main Execution (argument handling, startup)$ ./docker-cleaner.sh
> [1] Delete dangling images
β οΈ Found: 10 dangling images (~650MB)
ποΈ IMAGE ID SIZE CREATED
ποΈ 17fa649ad8a2 671MB 2 days ago
ποΈ e60fcc7a368e 495MB 3 days ago
...
β οΈ 10 dangling images (~650MB) really delete?
Confirm? (y/N): y
π§Ή Deleting dangling images...
β
10 dangling images deleted$ ./docker-cleaner.sh --test
> [6] Full cleanup (all above)
π§ͺ TEST MODE: Would run docker rmi $(docker images -f "dangling=true" -q)
π§ͺ TEST MODE: Would run docker rm $(docker ps -a -q --filter "status=exited")
π§ͺ TEST MODE: Would run docker volume prune --force
π§ͺ TEST MODE: Would run docker builder prune --all --force
β
Test mode completed - no actual deletions performed$ ./docker-cleaner.sh
> [5] Show detailed analysis
π Detailed Docker System Analysis
System Overview:
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 20 8 6.319GB 4.649GB (73%)
Containers 8 8 15.97MB 0B (0%)
Local Volumes 15 4 2.521GB 2.402GB (95%)
Build Cache 197 0 24.45GB 21.38GB
Image Statistics:
Total Images: 20
Dangling Images: 10
Running Containers: 8
Stopped Containers: 3- [1] Show all images sorted by size
- [2] System statistics (
docker system df) - [3] Show all images (including active)
- [4] Docker version & system info
- [5] Toggle test mode
Both scripts can be integrated into automated workflows:
# Cron job for weekly cleanup
0 2 * * 0 /path/to/docker-cleaner-en.sh --test
# Docker compose integration
docker-compose down
./docker-cleaner.sh --test
docker-compose up -d --build# Start Docker Desktop manually
# Or wait for Docker Desktop to fully initialize
open -a Docker# Make scripts executable
chmod +x docker-cleaner*.sh# Add Docker to PATH or use Docker Desktop
export PATH="/usr/local/bin:$PATH"- Ensure your terminal supports ANSI colors
- Use Terminal.app or iTerm2 on macOS
- Avoid running in basic text editors
Set verbose mode for troubleshooting:
# Enable verbose output
VERBOSE=true ./docker-cleaner.sh- Scripts are optimized for environments with hundreds of images/containers
- Pagination prevents overwhelming terminal output
- Progress indicators show operation status
- All operations work offline once Docker is running
- No external dependencies beyond Docker commands
- Fast execution with minimal system impact
- β Interactive menu system with beautiful UI
- β Dangling images cleanup (primary feature)
- β Container, volume, and build cache cleanup
- β Test mode and safety features
- β Detailed system analysis
- β English and German versions
- β macOS Terminal optimization
# Clone or download the scripts
# Test in safe environment first
./docker-cleaner.sh --test
# For development, you can modify safely
cp docker-cleaner.sh docker-cleaner-dev.sh
chmod +x docker-cleaner-dev.sh- Use bash 3.2+ compatibility (macOS default)
- Follow existing function naming conventions
- Maintain color scheme consistency
- Keep menus aligned and visually balanced
These scripts are provided as-is for Docker system maintenance. Feel free to modify and distribute as needed for your environment.
For issues or questions:
- Check the troubleshooting section
- Run with
--testmode first - Ensure Docker Desktop is running
- Verify terminal compatibility
π― Primary Use Case: The main purpose of these scripts is to safely remove dangling Docker images (<none>:<none>) that accumulate during build processes, reclaiming disk space while maintaining system safety through interactive confirmation dialogs and test mode capabilities.