Saturday, November 18, 2017

dpkg: error processing package docker.io (--purge)

docker icon
Uninstall (remove, purge) failed in Ubuntu 16.04 :
$ sudo aptitude purge docker docker.io
The following packages will be REMOVED:
  docker.io{p}
0 packages upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
Do you want to continue? [Y/n/?]
(Reading database ... 386398 files and directories currently installed.)
Removing docker.io (1.13.1-0ubuntu1~17.04.1) ...
Purging configuration files for docker.io (1.13.1-0ubuntu1~17.04.1) ...

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
Errors were encountered while processing:
 docker.io
E: Sub-process /usr/bin/dpkg returned an error code (1)
It gives a hint: /var/lib/docker, so:
$ # This will erase all your container images
$ sudo rm -rf /var/lib/docker
$ sudo aptitude purge docker.io
The following packages will be REMOVED:
  docker.io{p}
0 packages upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.
Do you want to continue? [Y/n/?]
(Reading database ... 386398 files and directories currently installed.)
Removing docker.io (1.13.1-0ubuntu1~17.04.1) ...
Purging configuration files for docker.io (1.13.1-0ubuntu1~17.04.1) ...
dpkg: warning: while removing docker.io, directory '/etc/docker' not empty so not removed
It gave another hint: '/etc/docker' not empty so not removed , so:
$ # This will erase all docker configs
$ sudo rm -rf /etc/docker/
$ sudo aptitude purge docker.io
Package docker.io is not installed, so it will not be purged
Package docker.io is not installed, so it will not be purged
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

Now if you need official and latest docker-ce (community edition) and docker-compose, see here:
https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/
https://docs.docker.com/compose/install/

~~~
Written with StackEdit.