The article provides a step-by-step guide on how to fully uninstall Docker from Ubuntu Linux. Docker, a platform that enables developers to run applications in portable containers, can be removed for reasons such as system conflicts, upgrades, or storage needs. The process involves stopping and removing Docker containers, images, networks, and caches before uninstalling Docker packages and deleting remaining files.
This article explains how to uninstall or remove Docker completely from Ubuntu Linux. It will show you how to delete Docker images, containers, configuration files, volumes, and packages.
Docker is a platform that allows developers to create, deploy, and run applications in containers easily. Containers are lightweight, portable, and self-sufficient environments containing all the necessary libraries and dependencies to run an application.
When you no longer need Docker on Ubuntu, you can uninstall the packages, but doing so won’t remove other images, containers, and configuration files. To properly remove Docker and related files, use the steps below.
There could be several reasons why someone may want to remove Docker from Ubuntu Linux. First, if they installed Docker to test it out or for a specific project and no longer need it, they may want to remove it to free up space on your system.
Sometimes, Docker may conflict with other software on your system, causing issues. You may want to remove Docker to resolve the conflict in such cases. If you want to upgrade to a new version of Docker, removing the previous version first is recommended.
Delete Docker images, containers, and volumes
As mentioned above, users can delete Docker images, containers, volumes, and other configuration files before uninstalling Docker.
Here’s how to do that.
First, stop the Docker containers that are running, then remove them.
Run the command below to do that.
docker stop $(docker ps -a -q)
The command will list all the Docker containers and stop them. Once they are stopped, run the command below to remove them.
docker rm $(docker ps -a -q)
Next, remove Docker images. Run the command below to do that. The command lists all the active and intermediate images and removes them from the system.
docker rmi $(docker images -a -q)
Next, remove all Docker networks. The command will remove Docker custom networks from the system.
docker network prune
Next, remove all cache and volumes. You can do that using the command below.
docker system prune -a
The command will perform the following actions:
- Remove all stopped containers
- Remove networks that are not used by at least one container
- Remove Images without at least one container associated with them
- Remove build cache
Confirm when prompted.
Finally, uninstall Docker packages and delete leftover files. You can do that by running the commands below.
sudo apt remove docker-* --auto-remove sudo rm -rf /var/lib/docker sudo groupdel docker sudo rm -rf /var/run/docker.sock sudo rm -rf /usr/local/bin/docker-compose && sudo rm -rf /etc/docker && sudo rm -rf ~/.docker
That should do it!
This post showed you how to uninstall Docker from Ubuntu Linux. If you find errors above or have something to add, please use the comments form below.