I installed Docker on Ubuntu a while back but when I tried to remove, the Docker still exists in the system. I followed this https://stackoverflow.com/a/31313851/2340159 but didn't work.
-
What exactly didn't work? – Grimmy Jun 26 '17 at 13:20
-
@Grimmy Thanks and kindly refer my answer – VithuBati Jun 26 '17 at 13:33
-
sudo rm -r / (problems dissapear) – aran Dec 16 '20 at 20:36
5 Answers
Probably your problem is that for Docker that has been installed from default Ubuntu repository, the package name is docker.io
Or package name may be something like docker-ce
.
Try running
dpkg -l | grep -i docker
to identify what installed package you have
So you need to change package name in commands from https://stackoverflow.com/a/31313851/2340159 to match package name. For example, for docker.io
it would be:
sudo apt-get purge -y docker.io
sudo apt-get autoremove -y --purge docker.io
sudo apt-get autoclean
It adds:
The above commands will not remove images, containers, volumes, or user created configuration files on your host. If you wish to delete all images, containers, and volumes run the following command:
sudo rm -rf /var/lib/docker
Remove docker from apparmor.d:
sudo rm /etc/apparmor.d/docker
Remove docker group:
sudo groupdel docker

- 11,525
- 3
- 38
- 38
-
Hi @Dmitriusan, Thank you for the prompt answer. Apparently the system I was using had the docker-ce not Docker. Thus, running sudo apt-get purge docker-ce did the trick – VithuBati Jun 26 '17 at 13:24
-
2You forgot `sudo rm -rf /etc/docker` and _then_ run `apt-get purge` .. otherwise it leaves a `pc` entry in the apt repos (`dpkg -l` still sees it). Also, you probably also want to remove `runc` and `containerd` which are installed by docker.io, so `sudo apt-get purge runc containerd docker.io` ... unless you already had `runc` and/or `containderd` before installing docker.io. – Normadize Feb 01 '18 at 01:54
-
https://github.com/moby/moby/issues/6077 this helped for in-between issue – lalithkumar Jun 24 '21 at 07:08
Apparently, the system I was using had the docker-ce not Docker. Thus, running below command did the trick.
sudo apt-get purge docker-ce
sudo rm -rf /var/lib/docker
hope it helps

- 1,918
- 1
- 18
- 26
-
2If you have made some configuration changes to docker(like me). You might want to consider `sudo rm -rf /etc/docker` as well. – Vivek Shankar Sep 26 '17 at 10:15
@miyuru. As suggested by him run all the steps.
Ubuntu version 16.04
Still when I ran docker --version
it was returning a version. So to uninstall it completely
Again run the dpkg -l | grep -i docker
which will list package still there in system.
For example:
ii docker-ce-cli 5:19.03.6~3-0~ubuntu-xenial
amd64 Docker CLI: the open-source application container engine
Now remove them as show below :
sudo apt-get purge -y docker-ce-cli
sudo apt-get autoremove -y --purge docker-ce-cli
sudo apt-get autoclean
Hope this will resolve it, as it did in my case.
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo rm -rf /var/lib/docker
sudo apt-get autoclean
sudo apt-get update

- 365
- 4
- 12