I tried using docker for something. That something failed, so I decided to uninstall docker.
The problem with removing docker
Ubuntu, and Debian both use the
apt package manager. This makes installing, removing, upgrading, etc. really easy.
So, I thought a simple
sudo apt purge docker.io
would do the job for me. And it seemed like that, until, out of nowhere:
Removing docker.io (1.13.1-0ubuntu1~16.04.2) ... '/usr/share/docker.io/contrib/nuke-graph-directory.sh' -> '/var/lib/docker/nuke-graph-directory.sh' Purging configuration files for docker.io (1.13.1-0ubuntu1~16.04.2) ... Nuking /var/lib/docker ... (if this is wrong, press Ctrl+C NOW!) + sleep 10 /var/lib/docker/nuke-graph-directory.sh: 64: /var/lib/docker/nuke-graph-directory.sh: shopt: not found dpkg: error processing package docker.io (--purge): subprocess installed post-removal script returned error exit status 127 Processing triggers for man-db (2.7.5-1) ... Errors were encountered while processing: docker.io E: Sub-process /usr/bin/dpkg returned an error code (1)
More specifically, the problem is in this line:
/var/lib/docker/nuke-graph-directory.sh: 64: /var/lib/docker/nuke-graph-directory.sh: shopt: not found dpkg: error processing package docker.io (--purge):
For those of you that don’t know what the
shopt command is(including me):
$ type shopt shopt is a shell builtin
shopt is part of bash. Naturally, the next reasonable thing is to view the contents of
/var/lib/docker/nuke-graph-directory.sh. The first line contained the following:
/bin/sh is the
dash shell, not bash. It is faster than
bash, but at the expense of quite a few features. So, in the shell
type shopt shopt: not found
Bam! I found the problem.
shopt, a shell builtin, simply does not exist in the shell the script was using.
It’s quite simple actually, just edit the
/var/lib/docker/nuke-graph-directory.sh file, and change the first line to:
This makes it so the script will be run with the
bash shell, which does have the
Time to try again!
sudo apt purge docker.io
This time, I got:
Nuking /var/lib/docker ... (if this is wrong, press Ctrl+C NOW!) + sleep 10 + rm -rf /var/lib/docker/containers /var/lib/docker/image /var/lib/docker/network /var/lib/docker/nuke-graph-directory.sh /var/lib/docker/overlay2 /var/lib/docker/plugins /var/lib/docker/swarm /var/lib/docker/tmp /var/lib/docker/trust /var/lib/docker/volumes dpkg: warning: while removing docker.io, directory '/etc/docker' not empty so not removed
Yay, one problem down! About
/etc/docker; I didn’t want it taking up space on my SSD, so a simple
rm -rf /etc/docker did the job. Docker is now fully uninstalled.
This is what I like about Linux
In Linux distros, you get a real error message if something goes wrong, not just “something went wrong”. If you know what you’re doing, fixing problems in Linux is much easier, thanks to amazing error and debugging logs. If something like this happened on Windows, you’d probably need at least a few days to find solutions, trying everything you see on the internet one by one. With Linux, read the error message, edit a file, and you’re done. Oh, and Linux is free Windows 10 is $100 :) .