Docker is a powerful tool for containerizing applications, but over time, your system can get cluttered with unused containers, images, volumes, and networks. If you’re looking to completely reset Docker and start fresh, this guide will walk you through everything you need to know.
Whether you’re troubleshooting or just want a clean slate, here’s how to remove all Docker resources in a few simple steps.
🔄 Why You Might Want to Reset Docker
There are many reasons you might want to reset Docker:
- Old images and containers are taking up space.
- You’re encountering weird behavior and want a fresh environment.
- You’re preparing your system for a new project or demo.
- You’ve made changes to your environment and want to clean up.
Whatever the reason, here’s the clean and safe way to do it.
đź§ą Step-by-Step: How to Reset Docker
⚠️ Caution: These commands will permanently delete containers, images, volumes, and networks. Make sure to back up anything important before proceeding.
1. Stop All Running Containers
First, stop all containers that are currently running:
docker stop $(docker ps -q)
2. Remove All Containers
Next, remove all containers (both running and stopped):
docker rm $(docker ps -aq)
3. Delete All Docker Images
Remove all Docker images from your system:
docker rmi -f $(docker images -q)
4. Delete All Volumes
Clean up volumes that may be taking up disk space:
docker volume rm $(docker volume ls -q)
5. Delete All Networks (Except Default Ones)
Docker comes with a few default networks (bridge
, host
, none
) which you shouldn’t remove. Here’s how to remove all custom networks:
docker network rm $(docker network ls | grep -v "bridge\|host\|none" | awk '{print $1}')
6. Clear Docker Build Cache
Docker’s build cache can take up a significant amount of space. You can remove it using:
docker builder prune -af
âś… One-Command Super Reset
If you want to do everything in one go, you can use this all-in-one command:
docker stop $(docker ps -q) && \
docker rm $(docker ps -aq) && \
docker rmi -f $(docker images -q) && \
docker volume rm $(docker volume ls -q) && \
docker network rm $(docker network ls | grep -v "bridge\|host\|none" | awk '{print $1}') && \
docker builder prune -af
🧨 Optional: Use Docker Desktop to Reset
If you’re using Docker Desktop, there’s a built-in reset option:
- Go to Settings.
- Navigate to the Reset tab.
- Click “Remove all data”.
This will remove all Docker data from your system.
🚀 You’re Ready to Start Fresh!
Once you’ve followed these steps, your Docker environment will be as good as new. This can help you avoid clutter, fix strange issues, and regain disk space. Now you’re ready to build clean and fast again!