Software & AppsOperating SystemLinux

How To Uninstall Docker from Ubuntu 20.04

Ubuntu 12

In this article, we’ll be going over a detailed guide on how to uninstall Docker from Ubuntu 20.04. Docker is a popular platform used for developing, shipping, and running applications. However, there may be instances where you need to uninstall it, and that’s what we’ll cover here.

Quick Answer

To uninstall Docker from Ubuntu 20.04, you can disable Docker using the snap disable command and then uninstall it using the snap remove --purge command. If you encounter any errors, you can try reinstalling Docker before uninstalling it. Alternatively, you can uninstall Docker using the apt remove command or manually remove Docker files and directories.

Disabling Docker

Before uninstalling Docker, it’s a good practice to disable it first. This can be done using the snap disable command. The snap command is a package management system that lets you install and manage packages in a secure sandbox environment. The disable option is used to disable a snap package.

sudo snap disable docker

This command will disable Docker, preventing it from running on your system.

Uninstalling Docker

Once Docker is disabled, you can proceed with uninstalling it. This can be done using the snap remove command with the --purge option. The remove option is used to remove a snap package, and the --purge option is used to remove the package along with its data.

sudo snap remove --purge docker

This command will uninstall Docker from your system and also remove its data.

Fixing a Corrupted Installation

In some cases, you may encounter an error while trying to uninstall Docker. This could be due to a corrupted Docker installation. If this happens, you can try reinstalling Docker before uninstalling it. This can be done using the snap install command. The install option is used to install a snap package.

sudo snap install docker

Once Docker is reinstalled, you can try uninstalling it again using the snap remove --purge command.

Alternative Uninstallation Methods

If the above methods don’t work, there are alternative ways to uninstall Docker.

Using apt

If you installed Docker using the apt package manager, you can uninstall it using the apt remove command. The remove option is used to remove a package.

sudo apt remove docker.io

This command will uninstall Docker from your system.

Manual Removal

If none of the above methods work, you can manually remove Docker files and directories. This method is more advanced and should be used with caution.

sudo rm -rf /var/lib/docker
sudo rm -rf /etc/docker
sudo rm -rf /var/run/docker.sock

These commands will remove Docker’s data directory, configuration directory, and socket file respectively.

After removing the files, you can also remove any Docker-related packages that might be installed.

sudo apt purge docker-ce docker-ce-cli containerd.io

This command will remove the Docker CE package, the Docker CE CLI package, and the containerd.io package.

Conclusion

Uninstalling Docker from Ubuntu 20.04 can be done in a few steps. It’s important to disable Docker before uninstalling it, and if you encounter any errors, you can try fixing the corrupted installation by reinstalling Docker. If all else fails, you can use alternative methods like using apt or manually removing Docker files and directories. Always remember to exercise caution when using these methods to avoid removing important system files.

Can I uninstall Docker without disabling it first?

It is recommended to disable Docker before uninstalling it to ensure that it is not running in the background. This can help prevent any issues during the uninstallation process.

What is the purpose of the –purge option in the snap remove command?

The –purge option in the snap remove command is used to remove the package along with its data. It ensures that all associated files and configurations are completely removed from the system.

What should I do if I encounter an error while uninstalling Docker?

If you encounter an error while uninstalling Docker, it may be due to a corrupted installation. In such cases, you can try reinstalling Docker before attempting to uninstall it again. This can help fix any issues with the installation.

How can I uninstall Docker if I installed it using apt?

If you installed Docker using the apt package manager, you can uninstall it using the apt remove command. Simply run sudo apt remove docker.io to remove Docker from your system.

Is it possible to manually remove Docker files and directories?

Yes, if the other methods fail, you can manually remove Docker files and directories. However, this method should be used with caution as it is more advanced. You can use commands like sudo rm -rf /var/lib/docker, sudo rm -rf /etc/docker, and sudo rm -rf /var/run/docker.sock to remove Docker’s data directory, configuration directory, and socket file respectively.

How can I remove Docker-related packages that might be installed?

To remove Docker-related packages, you can use the apt purge command. Run sudo apt purge docker-ce docker-ce-cli containerd.io to remove the Docker CE package, the Docker CE CLI package, and the containerd.io package.

Leave a Comment

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