How to set up Kali Linux on Docker QUICK AND EASY πŸ³πŸ±β€πŸ’»

Hey everyone today I am going to show you how to easily deploy a kali instance on docker and install all tools necessary to start your penetration tests with a single command !!!

I will start by supposing that you already have docker installed on your system, if you don’t have a look at their documentation on how to install on your OS here. (if you encounter a Hyper-V error while trying to deploy the machine on windows have a look at my post here)

Note: Do not forget to run the following commands on Linux distros using sudo and if you use Windows instead, you have to run powershell or cmd as administrator. Also to use docker you have to enable hyper-v therefore causing any machines that you use on VMware or Oracle VM to be unusable until you disable that again, but good news is that VMware will update their platform to support hyper-v in a near future !!!

Ok lets begin the first step is to pull the kali image from the docker repository here is the code for that:

docker pull kalilinux/kali-rolling

After this step completed you have to start a new “machine” to host the image:

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

The command /bin/bash will open a bash for you as root, let’s update our system so we can have the latest packages installed and updated:

apt-get update && apt-get install -y

Now for the last step, we will use a special command to install all tools that you would find on the traditional kali for VMs.

apt -y install kali-linux-large

This will take a while, during the installation the bash will stop and ask some preferences and settings for the applications being installed on the container, but mostly you can just press enter to skip them. They won’t affect your experience at all, well at least from what I have seen, but it still a good idea to have a quick look what each prompt is asking you for.

Bonus !!!

Ok, now that you are set let’s rename your container so then you don’t need to force yourself to use the random generated name by the docker. To check your name use the following command (remember to use a different bash than your container running linux)

docker ps

Now it will display something like this:


456465445656454 kalilinux/kali-rolling “bin/bash” today up 10 minutes arandomname

Now get the random name displayed on the prompt and write the following command:

docker rename arandomname myKali

Now type docker ps again a tah dah your machine is named to your desired name, you can find more command to use on docker on this page. Now have fun πŸ™‚

Hope I have helped you somehow, as always, have a wonderful day 🐳

Leave a Reply :)