Docker Cleanup Commands
February 11, 2025 ยท AI Conversations
### **1. Remove All Containers**
Run the following command to stop and remove all running and stopped containers:
docker rm -f $(docker ps -aq)
### **2. Remove MySQL Volume (if any)**
If your MySQL database is stored in a volume, find and remove the volume:
docker volume ls # List all volumes
docker volume rm <volume_name> # Remove MySQL volume (replace <volume_name>)
To remove all unused volumes:
docker volume prune -f
### **3. Remove All Images**
To delete all Docker images, run:
docker rmi -f $(docker images -aq)
### **4. Remove All Networks (Optional)**
To remove all networks except the default ones:
docker network prune -f
### **5. Remove All Unused Docker Resources (Optional)**
To clean up everything (stopped containers, unused networks, dangling images, and unused volumes):
docker system prune -a -f
Let me know if you need a specific cleanup! ๐
docker system df
This will display disk usage by containers, images, volumes, and build cache.
For more detailed information, use:
docker system df -v
Let me know if you need help cleaning up space! ๐