Installing Kali Linux in a Docker Container on Ubuntu

Today I’ve decided to take action and move away from booting Kali Linux from a USB pen drive. As awesome as Kali Linux and its full-featured toolset is, rebooting my Ubuntu-loaded laptop, booting to Kali Live, configuring the mouse settings, re-installing the wlan, not having any of my browser bookmarks, and further annoyances of booting from a USB version of Kali Linux each time is frustrating when I just want to try something I’ve read about or seen in a video on youtube. I haven’t had much luck with Virtual Machines, and I didn’t really want to run the 15GB ISO of Kali Linux with all of its tools, just to try something quickly now and then.

Solution? Install Docker on Ubuntu, and run a bare installation of Kali Linux + the top 10 tools included with the full-featured version, all from within the Ubuntu terminal.

Here’s how I did it.

Ethical Hacking and Pentesting using Kali Linux without leaving Ubuntu

14/04/2017–12:51 PM

Installing Docker on Ubuntu

First thing is first, install Docker. You probably know if you’re reading this, but my basic understanding of Docker is this: Docker is an open-source solution for being able to containerise your software in to a file system (which includes your code, runtime, system tools, libraries, packages, etc), and deploy software from within this container, which is a great thing. It prevents version and package compatability issues, and turns the deployment of applications and everything required for it to work properly in to one neat execution.

To successfully install Docker on Ubuntu, open your terminal, and follow these steps. If you have any issues, you can take a look at the official documentation for installing Docker CE on Linux in this link:

The steps for preparing your system for Docker are as follows:

  • Install the packages to allow apt to use a repository over HTTPS:

$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common

  • Add Docker’s official GPG key:

$ curl -fsSL | sudo apt-key add -

  • Verify that the key fingerprint is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88.

$ sudo apt-key fingerprint 0EBFCD88

  • Use the following command to set up the stable repository. You always need the stable repository, even if you want to install edge builds as well:


$ sudo add-apt-repository \ "deb [arch=amd64] \ $(lsb_release -cs) \ stable"

Install Docker:

Now you can move on and install Docker on your system.

  • Update the apt package index.

$ sudo apt-get update

  • Install the latest version of Docker, or go to the next step to install a specific version. Any existing installation of Docker is replaced.

Use this command to install the latest version of Docker:

$ sudo apt-get install docker-ce

  • Verify that Docker CE or Docker EE is installed correctly by running the hello-world image.

$ sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

Now Docker is installed and running. You need to use sudo to run Docker commands.

To upgrade Docker, first run sudo apt-get update, then follow the installation instructions, choosing the new version you want to install.

Kali Linux Docker Images

The next step is pulling an official Kali Linux distribution from their site.

You can visit Kali Linux’s blog post on their Docker Images which was posted in May 2015 here:

It’s as simple as it gets from here. Just pull their image for Kali Linux (it might take a while the first time) like so:

$ docker pull kalilinux/kali-linux-docker

Then run the container:

$ docker run -t -i kalilinux/kali-linux-docker /bin/bash

You’ll notice now that your terminal will say you’re now username root, which means you’re running Kali Linux’s base installation in the terminal via Docker.

Now, Kali Linux has a suite of Pentesting and Security tools built in, but within that Suite, there are the aptly named “Top 10” as seen here:

You can install Kali Linux’s “Top 10” tools, or any other Metapackage you prefer like so:

$ root@0129d62d2319:/# apt-get install kali-linux-top10

More information on the metapackages available can be found here:

This might take a while, because the top 10 security tools and the dependencies are around 3.5GB. Grab a coffee and if you want, browse the rest of my blog posts.

Once the downloads and installations are complete, you are officially running Kali Linux in a Docker Container in Ubuntu, complete with the Top 10 security tools.

Give it a try! Run an Nmap scan:

$ sudo nmap -sS

Success! You should have returned a Nmap scan report for in your terminal.

Hack away (ethically, of course).