Docker and Kali Linux

Recently the guys from Offensive Security released Kali Linux for Docker which is great news.

So firstly what is Docker?

Easiest thing to do is go over here and read all about it:
For a deeper explanation you can go here:

In simplistic terms it allows you can create the application you want to use and have it run really on anything without the need to create Virtual Machines running a guest Operating System. Imagine running your code on a system that doesn’t need an operating system loaded first, very cool if you ask me.

Virtual Machines


So what does this mean?
Well for one it allows us to create a template for an application that can be almost spun up in a controlled container easily. Containers allow segmentation of applications and as such means that I can spin up an Ubuntu image and then run different applications each isolated and protected.

Now Kali Linux is a great tool for penetration and security testing and normally requires a full Virtual Machine to work, however using Docker I can create a single Host and run multiple application and images.

How do you use it?
Well first lets spin up a host we can use, for this I am going to use DigitalOcean. Once you have an account simply click to create a Droplet.

For this “Droplet” I am going to call it “Docker” and then use the $5 a month image.

Next we need to select the operating system for the image as well as select from the applications what we need which is “Docker“.

Once we have it set we simply choose to create it which according to the site should be 60 seconds.

Once it loads you should see the configuration options that are available in the web user interface.

Now we need to connect to the “Droplet” which you can do once you get the email that it has been created along with the root username and password needed.

Now I can either connect using the web page or SSH into the “Droplet“.

You are asked to reset the password sent at first login, make sure you use a decent and complicated one (have to say that). Once we are in we can run the following simple command:

docker version

This will return the current version of “Docker“.

Next we can run commands to display the containers and images that we have. For now let’s focus on images by running the following command.

docker ps –a

This returns us nothing at the moment, once we have images it will list them.

So how do we get Kali Linux on our new “Droplet”?
This is really easy using the following three commands. This will pull down the image of “Kali Linux” to a “Docker” container

docker pull kalilinux/kali-linux-docker

Once completed we can then run the image which will load the image into its container and then give me a command prompt for the “Kali Linux” instance.

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

This should then change the command line to be the command line from “Kali“. First thing I am going to run an update.

apt-get update && apt-get upgrade

Due to the image been trimmed down, to utilize something like “Metasploit” you will need to install it. This can be done using a standard “apt-get” command.

apt-get install metasploit

Once it has completed you are able to then run “Metasploit” using the standard command.

msfconsole –L

As a note as it configures it for the first time it may come back and say “-killed”, no worries re-run the command and it will work fine.

Once it has been built it should then work as expected.

Now if we exit out of the “Kali Image” we can now run “docker ps –a” and we now should our image and the associated container.

All in all you probably wouldn’t need to launch a Virtual Machine, you would utilize something like “boot2docker” which installs all the pieces you need so you can run something like “Kali Linux” on a workstation easily without needing to setup everything.

If you want to use “DigitalOcean” then use this link:

Liam Cleary

Liam began his career as a Trainer of all things computer-related. He quickly realized that programming, breaking, and hacking was a lot more fun. He spent the next few years working within core infrastructure and security services until he found SharePoint. He is the founder and owner of SharePlicity, a consulting company that focuses on all areas of Technology. His role within SharePlicity is to help organizations implement technology that will enhance internal and external collaboration, document and records management, automate business processes, and of course security controls and protection. Liam also serves as the Principal Technology Advisor at Rencore, where he is helping to develop offerings that help organizations further understand and mitigate security and compliance risks, within SharePoint and Office 365 customization's. His core focus will is to identify, control, and protect whether they are full-fledged customization's or out-of-the-box Office 365 functionality. He is also a thirteen-time Microsoft MVP focusing on Architecture but also crosses the boundary into Development. He is also a Microsoft Certified Trainer (MCT). His specialty over the past few years has been security in SharePoint and its surrounding platforms. He can often be found at user groups or conferences speaking, offering advice, spending time in the community, teaching his kids how to code, raspberry PI programming, hacking the planet or building Lego robots.

You may also like...