How to Install Docker on Kali 2020.4

There is no apt install --unfuck

Featured image

Pictured: The magical fun of apt install -y docker.io as root.

TLDR

Trying to install docker.io on Kali 2020.4 from the official Kali repos gets upsetti spaghetti about an unmet dependency for libpod-parser-perl. Instead of installing it or telling you it’s missing, apt does the perfectly reasonable thing and tries to purge the kali core packages because that’s totally the sane option…

This issue is likely due to some dependency chain weirdness that will sort itself out soon enough. It’s not something you’ll come across often, and in fact is not something I’ve had to deal with for at least a couple of years now. Even so this is a good lesson as to why you never apt install -y unless you’re absolutely sure of what you’re doing.

Until it’s fixed, you’ll want to install both docker and libpod-parser-perl at the same time.

Our System

We’re working on Kali 2020.4, the latest release as of November 18, 2020.

┌──(kitsutron㉿lappentoppen)-[~]
└─$ uname -a
Linux lappentoppen 5.9.0-kali5-amd64 #1 SMP Debian 5.9.15-1kali1
 (2020-12-18) x86_64 GNU/Linux
┌──(kitsutron㉿lappentoppen)-[~]
└─$ cat /etc/os-release
PRETTY_NAME="Kali GNU/Linux Rolling"
NAME="Kali GNU/Linux"
ID=kali
VERSION="2020.4"
VERSION_ID="2020.4"
VERSION_CODENAME="kali-rolling"
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="https://www.kali.org/"
SUPPORT_URL="https://forums.kali.org/"
BUG_REPORT_URL="https://bugs.kali.org/"

The Problem

Following the official Kali guide, I decided to go ahead with installing Docker to make some of my lab work easier. Because I’m just that wee-bit overly paranoid, I was lucky enough to always try an install first with the –simulate option.

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt install docker.io --simulate
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer
required:
  libboost-iostreams1.71.0 libboost-thread1.71.0 libxml-dom-perl
  libxml-perl libxml-regexp-perl
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  cgroupfs-mount containerd libalgorithm-diff-xs-perl libclone-perl
  libcrypt-ssleay-perl libdbd-mariadb-perl libdbi-perl libfcgi-perl
  libfile-fcntllock-perl libhtml-parser-perl libintl-perl libintl-xs-perl
  liblocale-gettext-perl libmath-random-isaac-xs-perl libmodule-find-perl
  libmodule-scandeps-perl libnet-dbus-perl libnet-dns-sec-perl
  libnet-libidn-perl libnet-ssleay-perl libperl5.32
  libproc-processtable-perl libsocket6-perl libsort-naturally-perl
  libterm-readkey-perl libtext-charwidth-perl libtext-iconv-perl
  libxml-parser-perl needrestart perl perl-base perl-modules-5.32 runc
  tini
Suggested packages:
  containernetworking-plugins docker-doc aufs-tools btrfs-progs
  debootstrap rinse rootlesskit zfs-fuse | zfsutils-linux libmldbm-perl
  libnet-daemon-perl libsql-statement-perl perl-doc
  libterm-readline-gnu-perl | libterm-readline-perl-perl
  libtap-harness-archive-perl
Recommended packages:
  criu
The following packages will be REMOVED:
  davtest kali-linux-default kali-linux-headless libhttp-dav-perl
The following NEW packages will be installed:
  cgroupfs-mount containerd docker.io libintl-perl libintl-xs-perl
  libmodule-find-perl libmodule-scandeps-perl libperl5.32
  libproc-processtable-perl libsort-naturally-perl needrestart
  perl-modules-5.32 runc tini
The following packages will be upgraded:
  libalgorithm-diff-xs-perl libclone-perl libcrypt-ssleay-perl
  libdbd-mariadb-perl libdbi-perl libfcgi-perl libfile-fcntllock-perl
  libhtml-parser-perl liblocale-gettext-perl libmath-random-isaac-xs-perl
  libnet-dbus-perl libnet-dns-sec-perl libnet-libidn-perl
  libnet-ssleay-perl libsocket6-perl libterm-readkey-perl
  libtext-charwidth-perl libtext-iconv-perl libxml-parser-perl perl
  perl-base
21 upgraded, 14 newly installed, 4 to remove and 10 not upgraded.
...

Oh. Thanks apt, that’s exactly what I wanted. I totally wanted to blow away all the things and not do computers any more. Gold star.

Remv kali-linux-default [2021.1.3] [libhttp-dav-perl:amd64 ]
Remv kali-linux-headless [2021.1.3] [libhttp-dav-perl:amd64 ]

Installing docker by removing the core packages? This is fine.

We need those two packages. You could say they’re kind of a big deal. Clearly this will not do.

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt show kali-linux-default
Package: kali-linux-default
Version: 2021.1.3
Priority: optional
Section: metapackages
Source: kali-meta
Maintainer: Kali Developers <devel@kali.org>
Installed-Size: 18.4 kB
Depends: kali-linux-headless, kali-tools-top10, autopsy, cutycapt,
 dirbuster, faraday, fern-wifi-cracker, guymager, hydra-gtk,
 king-phisher, legion, ophcrack, ophcrack-cli, zaproxy, cherrytree,
 gparted, rdesktop, recordmydesktop, sqlitebrowser, tightvncserver,
 xtightvncviewer
Homepage: https://www.kali.org
Download-Size: 12.8 kB
APT-Manual-Installed: yes
APT-Sources: http://http.kali.org/kali kali-rolling/main amd64 Packages
Description: Kali Linux default system
 This is Kali Linux, the most advanced penetration testing and security
 auditing distribution.
 .
 This metapackage depends on all the applications that are included in
 official Kali Linux images.

Trying to simulate purging one of them and you’ll see what I mean.

Simpsons - Old man with Krusty doll: Purge this package. But beware, it carries a terrible curse.

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt purge kali-linux-default --simulate
NOTE: This is only a simulation!
      apt needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer
required:
  aircrack-ng amass amass-common arp-scan arping atftpd autopsy axel
  binwalk bluez-hcidump bulk-extractor bully bundler burpsuite
  ca-certificates-java cabextract cadaver cewl cgpt cherrytree chntpw
  cifs-utils clang commix crackmapexec cramfsswap creddump7 crunch
  cryptcat cryptsetup-nuke-password curlftpfs cutycapt cython3 davtest
  dbd dcraw default-jre default-jre-headless default-mysql-server dirb
  dirbuster dmitry dns2tcp dnschef dnsenum dnsrecon dos2unix enum4linux
  ethtool ettercap-common ettercap-graphical exe2hexbat exiv2 expect
  faraday faraday-client fastjar fern-wifi-cracker fierce figlet finger
  firebird3.0-common firebird3.0-common-doc flac fonts-dejavu-extra
  fonts-font-awesome fonts-lato fonts-lyx fonts-roboto-slab
  forensic-artifacts fping freeglut3 freerdp2-x11 freetds-common
  galera-3 gdal-data geoclue-2.0 gir1.2-gtksource-3.0
  gir1.2-javascriptcoregtk-4.0 gir1.2-soup-2.4 gir1.2-vte-2.91
  gir1.2-webkit2-4.0 gobject-introspection gparted gparted-common
  gpp-decrypt graphviz guymager hash-identifier hashcat hashcat-data
  hashcat-utils hashdeep hashid hdparm hotpatch hping3 hwloc hydra
  hydra-gtk hyperion ibverbs-providers ieee-data ifenslave
  iio-sensor-proxy ike-scan impacket-scripts inetsim iodine ipython3
  jarwrapper java-common java-wrappers john john-data
  kali-linux-headless kali-tools-top10 king-phisher kismet
...
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  kali-linux-default\*
0 upgraded, 0 newly installed, 1 to remove and 10 not upgraded.
Purg kali-linux-default [2021.1.3]

This list is pretty massive. I’ve truncated it so it doesn’t blow out the length of the article to something genuinely silly, but there’s at least 200 packages in there which are immediately marked as no longer required if you purge kali-linux-default.

Simpsons - Homer: That's bad.

The problem is when it’s trying to blow away libhttp-dav-perl.

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt purge libhttp-dav-perl --simulate
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer
required:
  libboost-iostreams1.71.0 libboost-thread1.71.0 libxml-dom-perl
  libxml-perl libxml-regexp-perl
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  davtest* kali-linux-default* kali-linux-headless* libhttp-dav-perl*
0 upgraded, 0 newly installed, 4 to remove and 31 not upgraded.
Purg kali-linux-default [2021.1.3]
Purg kali-linux-headless [2021.1.3]
Purg davtest [1.0-1kali4]
Purg libhttp-dav-perl [0.49-2]

For some reason it thinks it’s a good idea to burn down kali-linux-default when you remove libhttp-dav-perl which is not ideal.

Playing around with packages

Let’s try doing terrible things with apt to figure out where the problem actually lives. First let’s hold libhttp-dav-perl so it won’t get purged if we try to blow it away.

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt-mark hold libhttp-dav-perl
libhttp-dav-perl set on hold.

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt-mark showhold
libhttp-dav-perl

Now let’s tell apt to simulate installing docker again to see what breaks this time.

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt install docker.io --simulate
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libhttp-dav-perl : Depends: libpod-parser-perl
E: Error, pkgProblemResolver::Resolve generated breaks, this may be
  caused by held packages.

Aha! Sneaky bugger wants libpod-parser-perl.

What happens when we try to simulate installing docker.io and libpod-parser-perl?

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt install docker.io libpod-parser-perl --simulate
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer
required:
  libboost-iostreams1.71.0 libboost-thread1.71.0
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  cgroupfs-mount containerd libalgorithm-diff-xs-perl libclone-perl
  libcrypt-ssleay-perl libdbd-mariadb-perl libdbi-perl libfcgi-perl
  libfile-fcntllock-perl libhtml-parser-perl libintl-perl libintl-xs-perl
  liblocale-gettext-perl libmath-random-isaac-xs-perl libmodule-find-perl
  libmodule-scandeps-perl kibnet-dbus-perl libnet-dns-sec-perl
  libnet-libidn-perl libnet-ssleay-perl libperl5.32
  libproc-processtable-perl libsocket6-perl libsort-naturally-perl
  libterm-readkey-perl libtext-charwidth-perl libtext-iconv-perl
  libxml-parser-perl needrestart perl perl-base perl-modules-5.32 runc
  tini
Suggested packages:
  containernetworking-plugins docker-doc aufs-tools btrfs-progs
  debootstrap rinse rootlesskit zfs-fuse | zfsutils-linux libmldbm-perl
  libnet-daemon-perl libsql-statement-perl perl-doc
  libterm-readline-gnu-perl | libterm-readline-perl-perl
  libtap-harness-archive-perl
Recommended packages:
  criu
The following NEW packages will be installed:
  cgroupfs-mount containerd docker.io libintl-perl libintl-xs-perl
  libmodule-find-perl libmodule-scandeps-perl libperl5.32
  libpod-parser-perl libproc-processtable-perl libsort-naturally-perl
  needrestart perl-modules-5.32 runc tini
The following packages will be upgraded:
  libalgorithm-diff-xs-perl libclone-perl libcrypt-ssleay-perl
  libdbd-mariadb-perl libdbi-perl libfcgi-perl libfile-fcntllock-perl
  libhtml-parser-perl liblocale-gettext-perl libmath-random-isaac-xs-perl
  libnet-dbus-perl libnet-dns-sec-perl libnet-libidn-perl
  libnet-ssleay-perl libsocket6-perl libterm-readkey-perl
  libtext-charwidth-perl libtext-iconv-perl libxml-parser-perl perl
  perl-base
21 upgraded, 15 newly installed, 0 to remove and 10 not upgraded.
Inst libhtml-parser-perl [3.75-1] (3.75-1+b1 kali-rolling [amd64]) []
Inst libnet-dns-sec-perl [1.18-1] (1.18-1+b1 kali-rolling [amd64]) []
Inst libalgorithm-diff-xs-perl [0.04-6] (0.04-6+b1 kali-rolling [amd64]) []
Inst libxml-parser-perl [2.46-1+b1] (2.46-2 kali-rolling [amd64]) []
Inst libtext-iconv-perl [1.7-7] (1.7-7+b1 kali-rolling [amd64]) []
Inst libtext-charwidth-perl [0.04-10] (0.04-10+b1 kali-rolling [amd64]) []
Inst libterm-readkey-perl [2.38-1+b1] (2.38-1+b2 kali-rolling [amd64]) []
Inst libsocket6-perl [0.29-1+b2] (0.29-1+b3 kali-rolling [amd64]) []
Inst libnet-ssleay-perl [1.88-3] (1.88-3+b1 kali-rolling [amd64]) []
Inst libnet-libidn-perl [0.12.ds-3+b2] (0.12.ds-3+b3 kali-rolling [amd64]) []
Inst libnet-dbus-perl [1.2.0-1] (1.2.0-1+b1 kali-rolling [amd64]) []
Inst libmath-random-isaac-xs-perl [1.004-2+b5] (1.004-2+b6 kali-rolling [amd64]) []
Inst perl [5.30.3-4] (5.32.0-6 kali-rolling [amd64]) [libhttp-dav-perl:amd64 ]
Inst perl-modules-5.32 (5.32.0-6 kali-rolling [all]) [libhttp-dav-perl:amd64 ]
Inst libperl5.32 (5.32.0-6 kali-rolling [amd64]) [libhttp-dav-perl:amd64 ]
Inst perl-base [5.30.3-4] (5.32.0-6 kali-rolling [amd64]) [liblocale-gettext-perl:amd64 on perlapi-5.30.0:amd64] [libdbi-perl:amd64 libfcgi-perl:amd64 libdbd-mariadb-perl:amd64 libhttp-dav-perl:amd64 liblocale-gettext-perl:amd64 libfile-fcntllock-perl:amd64 libcrypt-ssleay-perl:amd64 libclone-perl:amd64 ]
Conf perl-base (5.32.0-6 kali-rolling [amd64]) [libdbi-perl:amd64 libfcgi-perl:amd64 libdbd-mariadb-perl:amd64 libhttp-dav-perl:amd64 liblocale-gettext-perl:amd64 libfile-fcntllock-perl:amd64 libcrypt-ssleay-perl:amd64 libclone-perl:amd64 ]
Inst liblocale-gettext-perl [1.07-4] (1.07-4+b1 kali-rolling [amd64]) [libdbi-perl:amd64 libfcgi-perl:amd64 libdbd-mariadb-perl:amd64 libhttp-dav-perl:amd64 libfile-fcntllock-perl:amd64 libcrypt-ssleay-perl:amd64 libclone-perl:amd64 ]
Inst libfile-fcntllock-perl [0.22-3+b6] (0.22-3+b7 kali-rolling [amd64]) [libdbi-perl:amd64 libfcgi-perl:amd64 libdbd-mariadb-perl:amd64 libhttp-dav-perl:amd64 libcrypt-ssleay-perl:amd64 libclone-perl:amd64 ]
Inst libfcgi-perl [0.79-1] (0.79-1+b1 kali-rolling [amd64]) [libdbi-perl:amd64 libdbd-mariadb-perl:amd64 libhttp-dav-perl:amd64 libcrypt-ssleay-perl:amd64 libclone-perl:amd64 ]
Inst libdbi-perl [1.643-2] (1.643-3+b1 kali-rolling [amd64]) [libdbd-mariadb-perl:amd64 libhttp-dav-perl:amd64 libcrypt-ssleay-perl:amd64 libclone-perl:amd64 ]
Inst libdbd-mariadb-perl [1.21-1] (1.21-1+b1 kali-rolling [amd64]) [libhttp-dav-perl:amd64 libcrypt-ssleay-perl:amd64 libclone-perl:amd64 ]
Inst libcrypt-ssleay-perl [0.73.06-1+b2] (0.73.06-1+b3 kali-rolling [amd64]) [libhttp-dav-perl:amd64 libclone-perl:amd64 ]
Inst libclone-perl [0.45-1] (0.45-1+b1 kali-rolling [amd64]) [libhttp-dav-perl:amd64 ]
Inst runc (1.0.0~rc92+dfsg1-5 kali-rolling [amd64]) [libhttp-dav-perl:amd64 ]
Inst containerd (1.4.3~ds1-1 kali-rolling [amd64]) [libhttp-dav-perl:amd64 ]
Inst tini (0.19.0-1 kali-rolling [amd64]) [libhttp-dav-perl:amd64 ]
Inst docker.io (20.10.0+dfsg2-1 kali-rolling [amd64]) [libhttp-dav-perl:amd64 ]
Inst cgroupfs-mount (1.4 kali-rolling [all]) [libhttp-dav-perl:amd64 ]
Inst libintl-perl (1.26-2.1 kali-rolling [all]) [libhttp-dav-perl:amd64 ]
Inst libintl-xs-perl (1.26-2.1 kali-rolling [amd64]) [libhttp-dav-perl:amd64 ]
Inst libmodule-find-perl (0.15-1 kali-rolling [all]) [libhttp-dav-perl:amd64 ]
Inst libmodule-scandeps-perl (1.29-1 kali-rolling [all]) [libhttp-dav-perl:amd64 ]
Inst libpod-parser-perl (1.63-2 kali-rolling [all])
Inst libproc-processtable-perl (0.59-2+b1 kali-rolling [amd64])
Inst libsort-naturally-perl (1.03-2 kali-rolling [all])
Inst needrestart (3.5-2 kali-rolling [all])
Conf libhtml-parser-perl (3.75-1+b1 kali-rolling [amd64])
Conf libnet-dns-sec-perl (1.18-1+b1 kali-rolling [amd64])
Conf libalgorithm-diff-xs-perl (0.04-6+b1 kali-rolling [amd64])
Conf libxml-parser-perl (2.46-2 kali-rolling [amd64])
Conf libtext-iconv-perl (1.7-7+b1 kali-rolling [amd64])
Conf libtext-charwidth-perl (0.04-10+b1 kali-rolling [amd64])
Conf libterm-readkey-perl (2.38-1+b2 kali-rolling [amd64])
Conf libsocket6-perl (0.29-1+b3 kali-rolling [amd64])
Conf libnet-ssleay-perl (1.88-3+b1 kali-rolling [amd64])
Conf libnet-libidn-perl (0.12.ds-3+b3 kali-rolling [amd64])
Conf libnet-dbus-perl (1.2.0-1+b1 kali-rolling [amd64])
Conf libmath-random-isaac-xs-perl (1.004-2+b6 kali-rolling [amd64])
Conf perl (5.32.0-6 kali-rolling [amd64])
Conf perl-modules-5.32 (5.32.0-6 kali-rolling [all])
Conf libperl5.32 (5.32.0-6 kali-rolling [amd64])
Conf liblocale-gettext-perl (1.07-4+b1 kali-rolling [amd64])
Conf libfile-fcntllock-perl (0.22-3+b7 kali-rolling [amd64])
Conf libfcgi-perl (0.79-1+b1 kali-rolling [amd64])
Conf libdbi-perl (1.643-3+b1 kali-rolling [amd64])
Conf libdbd-mariadb-perl (1.21-1+b1 kali-rolling [amd64])
Conf libcrypt-ssleay-perl (0.73.06-1+b3 kali-rolling [amd64])
Conf libclone-perl (0.45-1+b1 kali-rolling [amd64])
Conf runc (1.0.0~rc92+dfsg1-5 kali-rolling [amd64])
Conf containerd (1.4.3~ds1-1 kali-rolling [amd64])
Conf tini (0.19.0-1 kali-rolling [amd64])
Conf docker.io (20.10.0+dfsg2-1 kali-rolling [amd64])
Conf cgroupfs-mount (1.4 kali-rolling [all])
Conf libintl-perl (1.26-2.1 kali-rolling [all])
Conf libintl-xs-perl (1.26-2.1 kali-rolling [amd64])
Conf libmodule-find-perl (0.15-1 kali-rolling [all])
Conf libmodule-scandeps-perl (1.29-1 kali-rolling [all])
Conf libpod-parser-perl (1.63-2 kali-rolling [all])
Conf libproc-processtable-perl (0.59-2+b1 kali-rolling [amd64])
Conf libsort-naturally-perl (1.03-2 kali-rolling [all])
Conf needrestart (3.5-2 kali-rolling [all])

Success! No more shenanigans trying to remove packages docker had no business touching in the first place.

The solution

Turns out there’s an unmet dependency when installing docker.io where if you don’t have libpod-parser-perl it tries to uninstall libhttp-dav-perl which tries to take out the kali core packages with it. As you can imagine, this is bad.

To avoid nuking all the things for your shiny new container engine, do this instead:

┌──(kitsutron㉿lappentoppen)-[~]
└─$ sudo apt install docker.io libpod-parser-perl

Now you can start using docker with sudo systemctl enable docker --now