February 2021 update:
- These instructions have been tested and are working on Kali Linux 2021.01
- At the same time, Docker version that is available through Kali repositories is now quite fresh, so the easiest way to install Docker, unless you absolutely need the latest version, is:
sudo apt-get update && sudo apt-get install -y docker.ioat the time of writing, you actually get the same version (
20.10.3) using both methods, which might diverge in the future.
- Instructions below also make use of the new way of adding package signing keys to the system as
apt-keyis being deprecated (note, Docker documentation hasn’t been appropriately updated yet). More details here: https://github.com/docker/docker.github.io/issues/11625
This is a quick guide on how to install Docker Engine on Kali Linux using official Docker repositories, see the note above about OS-provided packages. These steps have been tested on Kali 2021.1.
This guide is based on official Docker documentation (https://docs.docker.com/engine/installation/linux/docker-ce/debian/), with slight modification as adding a repository doesn’t work (we’re adding Debian repository to Kali distro).
Raspberry Pi instructions have been tested to work on both 32-bit and 64-bit Kali Linux.
Since Kali Linux 2020.1, a non-root user is created by default, details here — https://www.kali.org/news/kali-default-non-root-user/.
Kali has a myriad of tools, but it you want to run a tool that is not included, the cleanest way to do it is via a Docker container. As an example, I was looking into a tool called
changeme (https://github.com/ztgrace/changeme) that scans for default passwords, released at DerbyCon 7. Doing it the Docker way:
docker run -it ztgrace/changeme /bin/bash
was easy and didn’t pollute the rest of the system with python dependencies etc. Also, there is an older version of the tool included in Kali package repositories, with Docker you can try new versions of existing tools without any library version conflicts etc.
I’m no Docker expert by any means, so if you’ve used Docker on Kali, feel free to share what you liked about it.
Before starting, ensure your Kali Linux is fully up to date.
Add Docker PGP key (saved to
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/docker-archive-keyring.gpg >/dev/null
Configure Docker APT repository (Kali is based on Debian testing, which will be called buster upon release, and Docker now has support for it):
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian buster stable' | sudo tee /etc/apt/sources.list.d/docker.list
For Raspberry Pi 32-bit — use the following command instead:
echo 'deb [arch=armhf signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian buster stable' | sudo tee /etc/apt/sources.list.d/docker.list
For Raspberry Pi 64-bit — use the following command instead:
echo 'deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian buster stable' | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
If you had older versions of Docker installed, uninstall them:
sudo apt-get remove -y docker docker-engine docker.io
sudo apt-get install -y docker-ce
For Raspberry Pi, use the following command instead:
sudo apt-get install -y --no-install-recommends docker-ce
aufs-dkms package errors out when trying to install on Raspberry Pi, by using
--no-install-recommends switch we avoid the issue by not installing
aufs-dkms, and Docker still works fine.)
sudo docker run hello-world
To allow your non-root user to use Docker, add the user to
sudo usermod -aG docker $USER
Log out and log back in for this change to apply. Note a warning from Docker documentation: the docker group grants privileges equivalent to the root user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.