Installing Docker in Kali Linux (updated for 2019.2)

- these instructions have been tested and are working on Kali Linux 2019.2
- added instructions for Raspberry Pi — tested on 32-bit Kali Linux on Raspberry Pi 3, I couldn’t get Docker to work on 64-bit yet
This is a quick guide on how to install proper Docker CE in Kali Linux that has been tested on 64 bit Kali 2019.1. There’s other guides which use outdated Docker repositories (you can tell by the package name — docker, docker-engine, or docker.io).
This guide is based on official Docker documentation (https://docs.docker.com/engine/installation/linux/docker-ce/debian/) as of February 2019, with slight modification as adding a repository doesn’t work (we’re adding Debian repository to Kali distro).
I’ve assumed you are using Kali as root, so sudo is not used throughout the commands below. Do sudo su - before typing the commands below if that’s not the case.
Why?
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 in Kali, feel free to share what you liked about it.
Preparation
Before starting, ensure your Kali Linux is fully up to date.
Add Docker PGP key:
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
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] https://download.docker.com/linux/debian buster stable' > /etc/apt/sources.list.d/docker.list
For Raspberry Pi — use the following command instead:
echo 'deb [arch=armhf] https://download.docker.com/linux/debian buster stable' > /etc/apt/sources.list.d/docker.list
Note: as mentioned, I couldn’t get Docker to work on 64-bit Kali Linux for Raspberry Pi yet, so you’ll need a 32-bit version. This should work on Raspberry Pi 4 as well, though I haven’t tested it yet.
Update APT:
apt-get update
Install Docker
If you had older versions of Docker installed, uninstall them:
apt-get remove docker docker-engine docker.io
Install Docker:
apt-get install docker-ce
For Raspberry Pi, use the following command instead:
apt-get install --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.)
Test:
docker run hello-world
After installation, Docker service will be started, but not enabled (i.e. it will not be started automatically after reboot). To start it:
systemctl start docker
To start Docker automatically upon reboot (do it on your own risk!):
systemctl enable docker
来源:https://medium.com/@airman604/installing-docker-in-kali-linux-2017-1-fbaa4d1447fe