How to factory-reset Docker on Linux, macOS, and Windows
Step-by-step Docker reset: stop containers, prune images and volumes, wipe /var/lib/docker on Linux, use the Reset to factory defaults button on Desktop, then verify with hello-world.
Sometimes Docker just gets weird. Disk fills up with dangling images, a daemon refuses to start, a container keeps coming back from the dead — and the fastest path forward is to wipe everything and start over.
This is the sequence I use when I want a clean Docker on Linux, macOS, or Windows.
Why Reset Docker?
Resetting Docker can be useful when your development environment becomes slow, cluttered, or difficult to troubleshoot.
Common reasons include:
- Troubleshooting persistent Docker issues
- Cleaning up unused containers, images, volumes, and networks
- Freeing up disk space
- Resetting Docker to a known state for testing or development
- Fixing configuration or daemon-related problems
Before continuing, back up any important containers, volumes, images, or configuration files. A full reset can permanently delete Docker data.
Step 1: Stop All Running Containers
First, stop all running containers to avoid conflicts or unexpected data loss.
docker stop $(docker ps -aq)
This command stops every container on your system.
If there are no containers, Docker may return a message indicating that no container IDs were provided. That is safe to ignore.
Step 2: Remove Containers, Images, Volumes, and Networks
Next, clean up unused Docker resources.
docker container prune -f
docker image prune -af
docker volume prune -f
docker network prune -f
Here is what each command does:
docker container prune -fremoves stopped containersdocker image prune -afremoves unused imagesdocker volume prune -fremoves unused volumesdocker network prune -fremoves unused networks
Be careful with volume pruning. Docker volumes often store database files, uploads, and other persistent application data.
Step 3: Perform a Deep Docker Cleanup
For a more complete reset, run:
docker system prune -af --volumes
This removes unused containers, networks, images, build cache, and volumes.
Use this command only when you are sure you no longer need the existing Docker resources.
Step 4: Reset Docker Configuration
The reset process depends on your operating system.
Linux
On Linux, you can remove Docker’s data directory for a deeper reset.
sudo rm -rf /var/lib/docker
You may also need to remove container runtime data:
sudo rm -rf /var/lib/containerd
Only run these commands after stopping Docker and confirming that your important data is backed up.
macOS and Windows
For Docker Desktop:
- Open Docker Desktop.
- Go to Settings or Preferences.
- Open Troubleshoot.
- Select Reset to factory defaults.
This resets Docker Desktop settings and removes local Docker data.
Step 5: Restart Docker
After cleaning or resetting Docker, restart the Docker service.
Linux
sudo systemctl restart docker
You can verify Docker is running with:
docker info
macOS and Windows
Restart the Docker Desktop application.
Once Docker starts again, test it with:
docker run hello-world
If the test container runs successfully, Docker is working again.
Best Practices for Docker Maintenance
A full factory reset should not be your first option every time Docker feels cluttered. Regular maintenance can help prevent common issues.
Keep Docker Updated
Keep Docker, Docker Desktop, and your base images up to date to benefit from security fixes, performance improvements, and compatibility updates.
Use Multi-Stage Builds
Multi-stage builds help reduce image size by separating build dependencies from the final runtime image.
Add a .dockerignore File
Use a .dockerignore file to exclude unnecessary files from Docker builds.
Example:
node_modules
.git
.env
dist
coverage
This keeps builds faster and prevents sensitive or unnecessary files from being copied into images.
Create Ephemeral Containers
Design containers to be stateless and replaceable. Store important data in volumes, managed databases, or external services instead of inside the container filesystem.
Troubleshooting Common Docker Issues
If Docker still does not work after resetting, check the basics first.
Check Docker Logs
On Linux, inspect Docker service logs:
journalctl -u docker --no-pager
Verify the Docker Daemon Is Running
sudo systemctl status docker
Check Disk Space
df -h
Low disk space can cause Docker builds, pulls, and containers to fail.
Review Firewall or Network Settings
Network restrictions, VPNs, proxies, or firewall rules can prevent Docker from pulling images or connecting containers.
Wrap-up
The short version: stop the containers, prune the resources, wipe the data directory if you’re on Linux or hit the Reset button on Desktop, then restart. docker run hello-world is the proof.
Back up volumes first if any of them hold data you care about — docker volume ls is cheap, restoring a deleted database is not.
Related
- Docker Tricks in 2026 — day-to-day cleanup, Buildx, Scout, and Compose tricks so you reset less often.
- Deploy WordPress with Docker — what to do once Docker is healthy again.
- Set up SSH for multiple Git accounts — another “configure once, stop fighting it” topic.