This is a powerful and destructive bash script that removes all Docker containers, images, volumes, and networks from your system. It's designed to give you a completely clean Docker environment — useful when you're troubleshooting, starting fresh, or reclaiming disk space.
WARNING: This script will delete all your Docker data irreversibly. Use with extreme caution.
- Stops all running containers
- Removes all containers
- Force deletes all Docker images
- Deletes all Docker volumes
- Removes all user-defined Docker networks
- Performs a full
docker system prune
including volumes
- Clone or download this repository:
git clone https://github.com/your-username/docker-cleanup-script.git
cd docker-cleanup-script
- Make the script executable:
chmod +x docker-cleanup.sh
- Run the script:
./docker-cleanup.sh
- Confirm when prompted:
WARNING: This will delete ALL Docker data!
Are you sure? (y/N): y
- Docker must be installed and running
- Bash shell (Linux/macOS or WSL on Windows)
The script includes a confirmation prompt to prevent accidental execution:
read -p "Are you sure? (y/N): " confirm
Only if you respond with y
(lowercase) will the cleanup proceed.
Resource | Deleted? |
---|---|
Containers | Yes |
Images | Yes |
Volumes | Yes |
Networks | Yes (excluding default bridge , host , and none ) |
Cache | Yes (via docker system prune ) |
This script is irreversible. Once executed, all data managed by Docker on your system will be lost.
Use only when you're absolutely sure you want to wipe your Docker environment.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature
). - Make your changes and commit them (
git commit -m "Add your feature"
). - Push to your branch (
git push origin feature/your-feature
). - Open a pull request with a clear description of your changes.
Ensure your code follows PEP 8 style guidelines and includes appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for details.
For issues, suggestions, or questions, please open an issue on GitHub or contact the maintainer at GitHub Issues.