272

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?

10 Answers 10

494

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 docker-compose-plugin
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce docker-compose-plugin

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
sudo rm -rf /var/lib/containerd
sudo rm -r ~/.docker

You have removed Docker from the system completely.

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

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

To find any potentially remaining files, you can run

sudo find / -name "*docker*"

If you want to delete everything listed (be careful because this is typically not what you actually want), you can run,

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.

6
  • 27
    the snap command is well enough but take care before you delete everything on your system with docker in the name!
    – davidbak
    Commented Jul 29, 2019 at 19:52
  • 1
    You saved my MAAS box :)
    – David West
    Commented Sep 6, 2019 at 21:20
  • 9
    The second part is not needed and just dangerous, at least run it without -exec `rm -rf` {} + first.
    – Cwista
    Commented May 11, 2020 at 20:35
  • 2
    The second part could delete files that belong to different packages, e.g. /usr/share/vim/vim80/syntax/dockerfile.vim
    – orestisf
    Commented Jul 8, 2020 at 9:25
  • 2
    That last find command has the potential to do more harm than good.
    – Dan
    Commented Jul 8, 2020 at 10:54
31

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
15

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
8

An update on uninstalling docker

Just an update on this, after I had to deal with the same issue.

Here is the official docker documentation on removing docker.


Remove the latest version:

Uninstall the Docker Engine, CLI, and Containerd packages:

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

Delete all images, containers, and volumes:

sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

Remove previous versions:

sudo apt-get remove docker docker-engine docker.io containerd runc
7

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,

3

Remove docker completly

dpkg -l | grep -i docker
sudo apt remove --purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
sudo apt autoremove -y
sudo apt autoclean
3

Refreshing installation of Docker desktop and docker-ce after testing installation of Docker Desktop

After uninstalling docker desktop from ubuntu 22.04 and docker-ce (removing everything)

Then reinstalling docker engine (ce) alone as I want to run docker instance on host and separately on qemu/virt and being able to run hello-world I was getting this error

$ docker ps Cannot connect to the Docker daemon at unix:///home/christian/.docker/desktop/docker.sock. Is the docker daemon running?

Despite the user having docker group membership and permissions.

What was happening that despite uninstalling docker-desktop completely and docker-ce and then reinstalling from scratch I kept getting this error. There was no .docker/desktop/ folder

I found a config.json file .docker/config.json

that had a line "credsStore": "desktop", "currentContext": "desktop-linux"

So I copied it to a .bak extension and from then docker commands work properly without sudo

So it looks like uninstalling Docker Desktop is leaving at least that leftover behind.

1
  • Yeah this is my exact use case. Docker Desktop on ubuntu is toxic waste. What a regret.
    – Williams
    Commented May 17 at 22:18
2
// check docker is installed or not
dpkg -l | grep -i docker

// remove volume , network , container and image files
sudo docker volume prune -f
sudo docker network prune -f
sudo docker container prune -f
sudo docker image prune -a

// remove docker
sudo apt purge docker
or
sudo apt remove docker

// remove dependency packages related to docker
sudo apt autoremove
sudo apt autoclean

for details : read

0
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.

1
  • The dpkg query gives thousands of dpkg-query: no path found matching pattern which is not very useful. Commented Nov 14, 2022 at 19:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .