How to reset Docker (Linux)

Caution: Resetting Docker is an irreversible procedure that eliminates all files and directories generated by Docker. Therefore, only do it when necessary and use caution.

Use the following terminal commands to reset Docker on Linux (tested on Ubuntu):

  1. Stop Docker: The Docker service needs to be stopped before performing any reset actions:

$ sudo systemctl stop docker

  1. Remove Docker Containers: To remove all containers, the running instances of your Docker images, use the following command:

$ sudo docker rm -f $(sudo docker ps -aq)

  1. Remove Docker Images: To remove all images, the templates for creating containers, execute the following command:

$ sudo docker rmi -f $(sudo docker images -aq)

  1. Remove Docker Volumes: To remove all volumes which are used for persistent storage of data, run this command:

$ sudo docker volume rm $(sudo docker volume ls -q)

  1. Remove Docker Networks: To remove all networks which are used to connect containers, execute the following command:

$ sudo docker network rm $(sudo docker network ls -q)

  1. Remove Docker Configurations: This command will delete all Docker-related files and configurations (settings & preferences). To do so, run this command:

$ sudo rm -rf /var/lib/docker

  1. Start Docker: To start the Docker service again, use the following command:

$ sudo systemctl start docker

  1. Check Docker Status: To check the current status of the Docker service, run this command:

$ sudo service docker status

Docker Service Status
Current Docker service status, including whether it’s running or stopped.
asterix Written by:

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *