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.

Soman Bandesha Updated 4 min read
How to factory-reset Docker on Linux, macOS, and Windows

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 -f removes stopped containers
  • docker image prune -af removes unused images
  • docker volume prune -f removes unused volumes
  • docker network prune -f removes 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:

  1. Open Docker Desktop.
  2. Go to Settings or Preferences.
  3. Open Troubleshoot.
  4. 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.