99

I followed the uninstall instructions here. Then I ran these commands:

sudo apt-get purge docker-engine
sudo apt-get autoremove --purge docker-engine
rm -rf /var/lib/docker

So after I did all this I ran this command to see if docker files are any where else:

sudo find / -name '*docker*'

I found several places where docker files still exists.

/etc
/sys
/lib
/usr
/usr
/run
/proc
/var

Docker exists in subfolders in the list above. I can post every path if you like. There is about 200 locations.

Is there a way to totally and completely remove docker everywhere?

154

To completely uninstall Docker:

Step 1

dpkg -l | grep -i docker

To identify what installed package you have:

Step 2

sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce  

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 commands:

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

You have removed Docker from the system completely.

| improve this answer | |
  • 9
    Additionally I had to delete /usr/local/bin/docker-compose. – Gaia Jul 9 '18 at 19:51
  • 12
    I also remembered to remove the /etc/docker directory and all contents – paulperry Nov 17 '18 at 21:48
  • 6
    I see Docker related entries when $ sudo iptables -L after this. – eugene Apr 9 '19 at 9:07
  • 12
    In my case, I had to use sudo apt-get purge docker-ce-cli as well. – irene Apr 23 '19 at 4:36
  • 6
    i also had to remove ~/.docker directory – SBH May 14 '19 at 7:30
20

If you are on Ubuntu, I find it much easier to uninstall docker if it is installed with snap. You simply do:

sudo snap remove docker

or, to avoid it creating back-up data for a snap you no longer require:

sudo snap remove --purge docker

and to delete all related files,

sudo find / -name "*docker*" -exec `rm -rf` {} +

IMPORTANT UPDATES

As mentioned in the comments,

The second part is not needed and just dangerous, at least run it without -exec `rm -rf` {} + first

and

The second part could delete files that belong to different packages, e.g. /usr/share/vim/vim80/syntax/dockerfile.vim

So better to see what is going to be deleted first.

| improve this answer | |
  • 16
    the snap command is well enough but take care before you delete everything on your system with docker in the name! – davidbak Jul 29 '19 at 19:52
  • 1
    You saved my MAAS box :) – David West Sep 6 '19 at 21:20
  • sudo find / -name "docker" -exec rm -rf {} + 2>/dev/null is what works for me – HashTables Mar 4 at 14:02
  • 5
    The second part is not needed and just dangerous, at least run it without -exec `rm -rf` {} + first. – Ecker00 May 11 at 20:35
  • 1
    The second part could delete files that belong to different packages, e.g. /usr/share/vim/vim80/syntax/dockerfile.vim – orestisf Jul 8 at 9:25
5

Add docker-ce-cli package also while doing purge of docker

sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli
| improve this answer | |
2

Collaborated list collected from above posts and comments fro removing docker and docker-compose:

sudo apt-get purge -y docker-engine docker docker.io docker-ce  
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce  
sudo umount /var/lib/docker/
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
sudo rm -rf /usr/bin/docker-compose
| improve this answer | |
0

You can identify the packages those files originated from with a command like dpkg-query -S $(sudo find / -name '*docker*' -print 2>/dev/null). Any such packages that you do not need, you can remove with sudo apt-get purge <package>. Please use care when you do so as some packages include some support for docker, but you might not want to remove, say, a text editor or a file manager for that reason.

If some files did not originate from packages (indicated by "dpkg-query: no path found matching pattern path"), you can remove them individually. Again, please use caution, as there may be files unrelated to the docker you want to remove, which simply have the string "docker" in their names.

| improve this answer | |
0

Steps performed in order to remove docker on Centos 7:

yum list installed|grep -i docker
yum remove containerd.io.x86_64 docker-ce.x86_64 docker-ce-cli.x86_64
groupdel docker
ls /var/lib/docker/
rm -rf  /var/lib/docker /etc/docker
rm -rf  /var/run/docker.sock 
rm -rf  /var/run/docker
find /var -iname "*docker*"

Hope this information could be helpful for someone.

Best regards,

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.