Created
July 29, 2024 17:21
-
-
Save ygorth/b4d9bb8bf41f5530c200b6c89ec88d39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Stop all running containers | |
echo "Stopping all running containers..." | |
docker stop $(docker ps -q) | |
# Remove all containers | |
echo "Removing all containers..." | |
docker rm $(docker ps -a -q) | |
# Remove all images | |
echo "Removing all images..." | |
docker rmi -f $(docker images -q) | |
# Remove all unused volumes | |
echo "Removing all unused volumes..." | |
docker volume prune -f | |
# Remove all unused networks | |
echo "Removing all unused networks..." | |
docker network prune -f | |
# Remove all dangling images | |
echo "Removing all dangling images..." | |
docker image prune -f | |
# Remove all unused containers, images, volumes, and networks | |
echo "Removing all unused containers, images, volumes, and networks..." | |
docker system prune -a -f --volumes | |
echo "Docker environment cleaned up." | |
# Optionally, clean Docker build cache | |
echo "Cleaning Docker build cache..." | |
docker builder prune -f | |
echo "All Docker environments cleaned." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment