You are currently viewing How to Uninstall Docker Ubuntu?

How to Uninstall Docker Ubuntu?

Docker is one of the most popular containerization tools, and it is utilized extensively by the majority of businesses today. Docker is a tool that assists developers in the process of building, testing, and deploying their applications in a seamless manner across several environments. It is one of the most useful tools available and is among the top products in the DevOps domain.

In certain circumstances, you may not be willing to use Docker, in which case you could want to remove it from your computer system. How can we do that?
If you are looking for reliable assistance to uninstall docker on ubuntu then SupportFly is one of the reliable docker consulting service providers. Its certified admins can assist you with every step of the procedure if you want to deal with this issue in an easy and trouble-free manner. Or if you want to do it manually, so in this article, we are going to learn how to uninstall Docker on Ubuntu operating system. Now let’s begin.

Why Uninstall Docker?

It is crucial to understand the reason why you may need to uninstall Docker in the first place before we get into the process of uninstalling Docker. Docker may need to be removed from your system for a number of reasons, including the following:

Upgrading to a Newer Version

When updating to a newer version of Docker, it is possible that you will first need to uninstall the previous version before installing the new one. This is due to the fact that installing a newer version of Docker over an older one can result in problems and failures.

Freeing Up Disk Space

Docker has the potential to use a substantial portion of the available disc space on your computer, particularly if you use a large number of images, containers, and volumes. Docker can be uninstalled to free up some space on your hard drive if you’re getting low on storage capacity.

No Longer Needed

If you find that you no longer require Docker on your computer, there is no reason to keep it installed. Docker needs to be uninstalled if you want to maintain a clutter-free and clean operating system.

Also Read: Our blog post on docker failed to compute cache key

Uninstall Docker on Ubuntu 22.04

There are several steps we will take to uninstall Docker and its containers.

1. Confirm the Docker Packages

The first thing you need to do is make a list of all of the Docker packages that are currently compatible with your version of Ubuntu. You can check the Docker version by using the dpkg command, or you can get a list of the packages that have been installed by doing the following:

- $ dpkg -1 | grep -I docker
Confirm the Docker Packages

2. Delete the Docker Images

Even if you delete all of the Docker packages, the images that you created will remain undamaged. Checking for available Docker images is the first step; use the following command to do so:

- $ docker images

Using the following command, delete all of the images that are currently available:

- $ docker rmi $(docker images -q)

The removal of all of the Docker images from your system was done by the command that we ran. This frees up the storage space that was previously occupied by the Docker images.

Delete the Docker Images

If we make another attempt at listing the images, we will see that there is not a single Docker image available on the system. This indicates that we were successful in removing each and every one of them.

Delete the Docker Images-1

3. Delete the Docker Containers

When working with Docker, it is necessary for you to create many containers. Before we can uninstall the Docker package, it’s necessary to ensure that they have been uninstalled first. Use ps -a to see a list of all the units that are available.

- $ docker ps -a
Delete the Docker Containers

You have the option of deleting each container on its own, but this is a time-consuming process, especially if you have a lot of containers. A more effective strategy is to use the rm command to remove all of the containers that are currently available.

- $  docker rm $(docker ps -aq)

After you run the rm command, all the container IDs of the containers that were removed are shown. Check the readily available containers to ensure that the containers have been removed after doing so.

Delete the Docker Containers-1

4. Delete the Docker Volumes

These are the Docker volumes you generated. The rm program will help you get eliminated from them. Create a list of the volumes that are available. Then, in the following format, specify the names of the volumes that you want to remove from the system:

- $ docker volume 1s 
- $ docker volume rm <volume-name>
Delete the Docker Volumes

The space occupied by your Docker volumes has been removed, and it is now accessible to the host system.

Delete the Docker Volumes-1

5. Delete the Docker Networks

Verify that the ls command did not result in the creation of any networks that you are responsible for. The Linux Hint Network can be found in this location. Use the rm command in order to delete the network.

- $ docker network Is 
- $ docker network rm linuxhint
Delete the Docker Networks

You also have the alternative option of using the prune command to remove all of the networks. The following is an example of how we can delete the “neww” network:

- $ docker network prune
Delete the Docker Networks-1

At this stage, you are prepared to uninstall Docker on Ubuntu.

6. Uninstall the Docker Package

After you found out which Docker packages are currently installed on your computer, you can remove them by executing the following command:

- $ sudo apt-get purae -y docker.io

At this point, we will uninstall docker.io program. It is important to keep in mind that we chose to uninstall Docker packages last since uninstalling the Docker packages won’t remove your images, containers, volumes, or anything else.

Uninstall the Docker Package

It is important to note that the Docker directory is not deleted even after the program has been uninstalled.

Uninstall the Docker Package-1

When you reach the very last line, you will see a message informing you that the /etc/docker and /var/lib/docker/ folders are still available on your computer.

It is possible for us to check that the Docker files are still present on our system.

Uninstall the Docker Package-2

Using the following command, remove the following directories from your system:

- $ sudo rm -rf /var/lib/docker/ /etc/docker/
Uninstall the Docker Package-3

Also, remove the Docker group that was made during the installation of Docker from your system.

- $ sudo groupdel docker
Uninstall the Docker Package-4

In the final phase, uninstall the Docker socket from your computer.

- $ sudo rm -rf /var/lib/docker.sock
Uninstall the Docker Package-5

Conclusion

Docker is a great instrument for setting up and managing application environments. On the other hand, if you find that you no longer require Docker to be installed on your computer system, you are able to uninstall it together with any and all containers, images, networks, etc. that it may have created. The following article guided you through the process of uninstalling Docker and all of its containers from Ubuntu and presented each step in detail for your benefit. By following this instruction, you have successfully uninstalled Docker, thereby clearing space for the installation of new tools or another version of Docker.

Docker may be easily uninstalled on Ubuntu, but starting over with nothing at all needs paying attention to the minor points of the procedure. A clean uninstallation is an initial step towards achieving a more simplified development environment. This is true whether you are looking at alternative containerization solutions or resolving difficulties related to Docker.