Horje
How to Uninstall Docker From Ubuntu ?

Docker brought a revolution in the management of applications for developers and system administrators with containerization. Containers are a way to package an application and its dependencies into one portable and independent entity. This makes it easy to develop, ship, and consistently run applications in any environment.

There might come a moment when you have to uninstall Docker from your Ubuntu system. This might be troubleshooting issues, migrating to another containerization tool, or you just want to clean your system. The task of simply uninstalling Docker may appear minor. Still, in a systematic manner it is necessary so that all of its parts, dependencies, and related files are entirely taken out.

This guide will show how to thoroughly remove Docker from an Ubuntu system without leaving behind any residual files or configurations. The following steps will optimize a clean system to install new applications or tools.

Primary Terminologies

  • Docker: Docker is a tool designed to make it easier to create, deploy, and run applications using containers, a container bundles software in a format that includes everything needed to run it: code, runtime, system tools, and libraries.
  • Container: It is a lightweight, stand-alone executable software package that includes everything for running software, such as code, runtime, libraries, and system tools. Containers also ensure that the apps are consistent in all environments.
  • Docker Engine: This is Docker’s core part, where the running and management of containers take place on a host system. It includes a daemon, API, and command-line interface.
  • Docker CLI: This is another client used to send commands to the Docker daemon and interact with it, enabling users to manage docker objects like containers, images, networks, and volumes.
  • Advanced Package Tool (APT): An infrastructure operating on the Debian Linux distribution, including Ubuntu, that simplifies the installation, updating, and removal of packages of software.
  • Purge: In the context of package management, purging a package means removing the package and its configuration files from the system, this process is more thorough than just removing a package, which might leave configuration files around.
  • Autoremove: APT command meant for removing automatically installed packages that were only installed to satisfy the dependency of other packages and are no longer needed.
  • Autoclean: A kind of APT command used to clean up downloaded packages that are left out and can no longer be downloaded from a local cache.
  • Systemd: A system and service manager, an element required in a Linux operating system, is used to bootstrap the system and manage processes after booting.
  • Stat: A command that can display information about files or file systems, such as size, permissions, and modification dates. In Docker, the command is often used to check on the existence or state of files.

Step-by-Step Process for Uninstalling Docker

The following are the steps that guides you on uninstalling the docker from ubuntu:

Step 1: Check Docker Version

  • To verify that docker was installed or not by using following command
sudo docker --version
checking docker version

Step 2: Stop Docker Services

  • It is essential to stop all Docker services before uninstalling docker.
sudo systemctl stop docker
stopping the docker service

Step 3: Uninstall Docker Packages

  • Remove Docker packages from your system using the APT package manager:
  • This command uninstalls Docker Engine, CLI, containers, and associated packages.
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
listing all theavailable softwares

Step 4: Remove Docker Dependencies

  • Remove any Docker dependencies that may have been included with the configuration files of Docker
sudo apt-get autoremove -y
sudo apt-get autoclean
autoremoving of softwares

Step 5: Delete Docker Directories

  • Docker creates a few directories that store images, containers, volumes, and configuration files.
  • These directories should be removed to thoroughly uninstall Docker from your system.
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
removing the docker home directory

Step 6: Verify Docker Removal

  • Check that Docker has been successfully uninstalled by running the following command
docker --version
  • This command should return an error stating that Docker is not found.
removing containerd directory

Conclusion

Many times, users need to uninstall Docker from their Ubuntu systems for specific reasons, like troubleshooting a problem, switching to any other containerization tool, or simply keeping the system clean from clutter. However easy this may sound, the procedure has to be systematic for all components of Docker, its dependencies, and its residual files to be completely disposed of.

This article has elaborated on the processes involved in uninstalling Docker from the Ubuntu system: essential steps such as stopping services, purging Docker packages, removing dependencies, and erasing Docker directories. By following these steps, you can make sure that the uninstalls are done cleanly and wholesomely and that a single file and configuration remain which is associated with Docker in any way on your system.

It is essential to understand primary terminologies and the significance of each step in the uninstallation process to derive the desired output. This not only ensures that the system remains clean but puts the system in a position fit for future installations or transitions into other containerization tools.

Proper uninstallation of Docker ensures system resources are optimized, and it guarantees there is no conflict or residual configuration which might affect another application’s performance or behavior, adequate uninstallation for Docker will be an important, extraordinary skill for you as a developer, system administrator, or even enthusiast ineffective system management.

Uninstallation of Docker on Ubuntu – FAQs

How do I verify that Docker is wholly removed from the system?

After following these steps for uninstallation, you may try some of the below: docker –version or which docker. These commands should show that Docker is not found if it is entirely removed, additionally you could check whether /var/lib/docker and /var/lib/containerd have any Docker directories and configuration files left over.

What should I do when the Docker service is not stopping?

You can forcefully stop the Docker service using sudo systemctl stop docker –force. If it is still not stopping, then as a final action, you can reboot your system and then again try stopping the services. Diagnostics regarding the service can also be checked using sudo systemctl status docker.

Should I manually clean up Docker images and containers before uninstalling Docker?

Uninstalling Docker and deleting directories (/var/lib/docker and /var/lib/containerd) removes all images, containers, and volumes from the system. If there is some unique data that you don’t want to lose, ensure to back it up before the uninstallation process. You can use docker save for exporting images and docker export for exporting containers.

Can I reinstall Docker after the uninstallation?

Yes, the official Docker installation guide for Ubuntu can be used to reinstall Docker at any time. Uninstalling is not going to prevent anything in future scope. Make sure to follow the steps of installation correctly for setting up Docker.

What about my Docker data after uninstalling?

All data related to Docker, images, containers, and volumes will be removed once you delete the directories of Docker (/var/lib/docker and /var/lib/containerd). Make sure you’ve got a vital data backup before removing Docker. If you just purge without removing these directories, some data might persist.




Reffered: https://www.geeksforgeeks.org


DevOps

Related
Understanding Kubernetes Node Selectors Understanding Kubernetes Node Selectors
What is Nagios? What is Nagios?
How to Debug in Docker? How to Debug in Docker?
Console Vision App with .NET Console Vision App with .NET
Microsoft Azure - Cognitive Services Microsoft Azure - Cognitive Services

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
16