Kali Linux

How to Use Kali Linux Docker Images- Installing and Running Kali Linux on Docker

How to Use Kali Linux Docker Images

Kali Linux is a popular hacker-distro used by security professionals and ethical hackers all over the world. It is packed with a lot of security and privacy tools that you can use for vulnerability scanning, network and penetration testing. It is the most preferable operating system that includes all the things needed to become your ultimate weapon for protecting your system from cyber threats.

You can install Kali Linux as a stand-alone operating system, on VirtualBox, VMWare, on a Live USB and more. Besides that, you can also use built-in Kali Linux docker images to run the Kali Linux system on any environment either Windows, Linux or Mac. The advantage of using the Kali Linux docker images is that you don’t have to manually install the operating system from scratch.

In this guide, you will learn:

How to Use Kali Linux Docker Images

To learn how to use Kali Linux docker images, follow the below-given steps:

Step 1: Install Docker on a System

To run Kali Linux docker images on a system, you must install docker on your system. The official repository of the Linux system has included the docker packages that makes it easy for you to install docker on your system. However, before that, it is recommended to update your Linux repository using:

sudo apt update && sudo apt upgrade

After that, issue the below command for installing docker on your system:

sudo apt install docker.io -y

To ensure docker is successfully installed on a Linux system, run the below-given command:

docker --version

You can also install docker on a Linux system by first adding the following Linux repository:

printf '%s\n' "deb https://download.docker.com/linux/debian bullseye stable" |

sudo tee /etc/apt/sources.list.d/docker-ce.list


Then adding the GPG key to verify the authenticity of the added repository:

curl -fsSL https://download.docker.com/linux/debian/gpg |

sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-ce-archive-keyring.gpg


Once done, update your repository through the below-given command to ensure the docker repository is successfully added to your system:

sudo apt update

After updating the repository, the docker can be installed on the system along with additional command-line tools using the following command:

sudo apt install docker-ce docker-ce-cli containerd.io -y

Step 2: Enable Docker on a System

After completing the docker installation on a system, you can enable it on your Linux system from the below command:

sudo systemctl enable docker --now

Step 3: Add Docker to sudo group

By default, the docker commands can be run with sudo privileges, however, you can run it without sudo by adding the docker user to a sudo group from the provided command:

sudo usermod -aG docker $USER

Replace $USER in the above command with the username you want to add to the sudo group.

Note: The Windows users can use docker commands on a system by installing the Docker Desktop App. After that, open Command Prompt or Windows PowerShell and execute the docker commands given below to use Kali Linux docker images on Windows.

Here, we are using Kali Linux as a base system for running the commands. But, you can use the commands to run Kali Linux docker images on any Linux or Windows distribution where docker is installed.

Step 4: Pull the Kali Linux Docker Image

After adding the user to a sudo group, you can run the following command to pull the official Kali Linux rolling docker image on your Linux system:

docker pull docker.io/kalilinux/kali-rolling

Note: In case you experienced permission denied error, this could be because you have skipped Step 3 and to avoid it, use sudo with the docker command.

Step 5: Run the Kali Linux Docker File

Once the pulling is completed, you can run the below-given command to run the Kali Linux docker images on your system:

docker run --tty --interactive kalilinux/kali-rolling

The above command will enable and run the Kali Linux environment on your system.

Step 6: Update Kali Linux Repository

You can update the Kali Linux repository to ensure the installation is completed, this can be done from the below command:

apt update

Step 7: Install Kali Linux Headless

The Kali Linux system docker image doesn’t include penetration testing or other advanced tools. Instead, it allows you to install only basic packages on your system. For that purpose, you have to install a specific meta-package called kali-linux-headless on your system using the following command:

apt install kali-linux-headless -y

During the installation, you will be asked for some onscreen choices that you have to choose from to complete the setup.

Note: Further, you can also install other Kali Linux meta-packages that offer a wide range of tools that allows you to kick-start your ethical hacking journey. You can get help to install different Kali Linux meta-packages by navigating to the official website.

How to Resume Existing Docker Container

If you have logged out your device or close the terminal accidentally, you can resume the existing docker container. It is possible by first running the following command to check for the docker containers list:

docker container list --all

Then run the docker start command followed by the container ID to start the container on the system:

docker start container_ID

Once the docker container is started, simply run the docker attach command followed by the container ID to resume it on your system:

docker attach container_ID

How to Remove Docker Container

If you want to remove the docker container from the list, you have to first stop the docker container by using the docker stop command with the container ID:

docker stop container_ID

Then use docker rm command followed by the container ID you want to remove from the list:

docker rm container_ID

Conclusion

Kali Linux docker images allows you to run the Kali Linux environment on any operating system. To use Kali Linux docker images on a Linux system, you must ensure docker is installed on your system. If you are using Windows, you can install Docker Desktop and use docker commands. For Linux systems, docker can be installed from the official Linux repository or adding docker repository and installing it from apt command. We have provided the necessary steps to use Kali Linux docker images on any system. We have also provided the methods to run docker containers, resume existing docker containers and remove the docker container from the system.

 

Similar Posts