Setting up Kali Linux in Docker on Windows 10


A few times now, I find myself wondering why I need a full blown VM. I like need to quickly get my tools up and running on any hardware I find myself on. Most of the time that is a fresh installed Windows 10 on my Surface Book—I like messing things up to a point of no return… what can I say?

As I illustrated the beauty of "Bash on Ubuntu on Windows" in the Azure Security Center's SQL-Injection Playbook, I realized there really must be a better way to bring Kali Linux over to Windows as well. As many know, Kali is a customized Linux distribution, based on Debian. I could, in theory, install Ubuntu and install the Kali repositories and go from there—in addition, I like to stay away from multiple repositories from multiple parties on the same packages. Possible, but a configuration nightmare to maintain and troubleshoot. Kali's official documentation seems to agree with me.

The next best thing is Containers. In the Windows world, this requires Windows 10 Anniversary Edition+. You'll be able to enable Containers, Install Docker, and pull a Kali Linux image all in 10 minutes or less (download speeds may vary ).

Installing the Containers Feature and Installing Docker

First, we must enable the "Containers" feature. Run (ctrl+r) "optionalfeatures".

And make sure this "Containers" option is checked off.

Once that completes, follow these instructions to install docker: https://docs.docker.com/docker-for-windows/install/. Grab the Stable channel Windows MSI and install it. Once you get it to install, you need to log out and log back in. NOTE: Although Docker stated it just needed a log-out/log-in, in order for the Docker service to run on my machine it required a reboot.

After logging back in, in your notifications, you should get a "Docker is starting…".

Pull Official Kali Linux Docker Image

We will be following the guidance here: https://www.kali.org/news/official-kali-linux-docker-images/

Open up your favorite command line interface (CLI). Then type "docker pull kalilinux/kali-linux-docker". This will pull the image from the Docker Store.

Now, let us enter an interactive bash session with that image by typing "docker run -t -I kalilinux/kali-linux-docker /bin/bash"

We are now in our fresh install of Kali. Since this install is meant to be the minimal, you need to grab the packages you actually care about. This helps keep the image small but does require a good Internet connection to get up and running.

Before installing any package, let's upgrade our Kali Linux and remove all packages we no longer need via "apt update && apt full-upgrade && apt auto-remove && apt-autoclean"

Installing the Metasploit Framework

Lastly, let us install the go-to package for most pentesters… Metasploit. A simple command of "apt install metasploit-framework ruby" will do the trick.


Just start up the PostgresSQL database that Metasploit uses, initialize the database, and to msfconsole we go!

Happy Hunting,

Andrew (@ciberesponce)


Comments (16)

  1. L.M. says:

    This is great and complimentary to carrying around Kali on USB. I’ll be trying this out soon.

  2. Jake says:

    Why don’t you just commit the container after installing metasploit? Or better yet, create an automated build on dockerhub that allows you to pull down a metasploit container whenever needed?

    1. kplaxmaster says:

      You should absolutely commit changes in the Container 🙂 once of course your done doing all the updates and packages you need out of the gate that is (as Metasploit by itself probably wouldn’t suffice most folks). This post isn’t meant to be a full fledged Docker-How-To or a Kali-Linux How-To. This is simply how to get folks up and running if they wanted to explore Kali in Docker–which I find much more efficient than a full-fledged VM and much less intrusive than a dual-boot. Not to say anything is wrong with those solutions–it just depends on what your familiar with and what problem your trying to solve.

  3. Dan says:

    Could you also create a docker file to run the installs at creation of the container?

    1. kplaxmaster says:

      Yes, or better yet you should modify the minimal Kali Linux install to your needs, and then ‘docker commit‘ the changes in the container to a new image. This way, every time you spawn a new container from that new image, it has all the tools you need.

  4. Benny says:

    > A few times now, I find myself wondering why I need a full blown VM.

    You realize that you are running a full blown VM when you install Docker for Windows… The only differ is that you do not see it because its auto installed ( unless you look at the 2GB memory usage ).

    1. kplaxmaster says:

      The git-like features that Docker brings to the table in the “virtualization” world (you are absolutely correct that its a VM, in fact you can even see it in Hyper-V Admin if you enable that), are to me worth it. Of course you could argue that you can do that via snapshots and what not in Hyper-V/ESX. As for Windows vs Linux in terms of Docker implementation, how Hyper-V does VBS/containment vs LXC, I’m not expert in that but I’d certainly be curious on the security differences there.

      So, in summary, great point 🙂

  5. A. V. says:

    Need help. I follow the instruction above and everything when as is listed. However, I can’t make it to run. Here is the commands, I invoking, by the way is on windows 10: “docker run -t -i kalilinux/msf” and “docker run -t -i kalilinux/msf /bin/bash” none of those work. What am I missing thanks.

    1. kplaxmaster says:

      Are you getting an error message? I’d recommend you ask this question to Stack Overflow for the best audience that can help you!

  6. rajesh says:

    is that possible to use klai linux in gui???? installed in docker on windows 10.
    and what are the cons in using kali in docker..
    thank you

    1. kplaxmaster says:

      Docker doesn’t support GUI. There is no reason though on why you couldn’t host services in there and access them via the host computer from the browser. You would just need to play with the ports and docker configuration, of course.

  7. rajesh says:

    i installed metasploit on kali linux installed on docker on woindows 10 and ran it successfylly, but after restarting my pc metasploit is nowhere in directory and i cant even open metasploit,please help me what was the problem

    1. kplaxmaster says:

      when you make File system changes (which you are doing with apt/apt-get), make sure you make commits back to the Docker container. If not, each time you run from the same container, the changes won’t be there. What I do is make the OS-level changes I want, commit that back and each customer/test always starts from that good clean (updated and all-inclusive) docker container).

    2. kplaxmaster says:

      Make sure you commit your changes. Think of Docker as a way to start from a gold disk, and every change you make disappears when you turn off that container unless you sync the changes back to the docker image. This way you can have a separate Kali distro for each customer you are doing pen testing for, for example. For this reason its also big in cloud computing!

  8. Lara says:

    Thanks for your useful article. I admit that i am new to Docker so, i would really appreciate your help. My question is, i need to add security testing feature to a web app we are planning to start. I found different available images for penetration testing tools such as kali and metasploit. What kind of issues i could expect to happen during the continuous integration process.

    1. kplaxmaster says:

      Lara, Metasploit is also a component of Kali. Kali does a great job integrating tools together and ensuring from the start that they work with minimal configuration on your end. However, there are other solutions similar to that. Do know that there is a trade off as some distros try to get close to the source code of individual programs when they are updated, while others wait after the software is released to ensure its properly integrated to the rest of the system.

Skip to main content