top of page
Search
  • Writer's pictureotw

Getting Started with Docker, Part 1: Installing Kali Linux in a docker Container

Updated: Oct 23, 2023


Welcome back, my aspiring cyberwarriors!


Increasingly, we are seeing cybersecurity tools and apps using docker. For instance, in my tutorial on IP camera credential brute forcing, we used docker to contain our app. To help you understand docker, Aircorridor has written a short tutorial here to explain what it is and how it works.


What is Docker?

Docker is an open-source platform for developing, shipping, and running applications. It uses OS (operating system)-level virtualization to create containers, which are lightweight, standalone packages that include everything an application needs to run: code, libraries, and dependencies. Containers isolate applications from the underlying system, making them consistent and portable.


Docker simplifies the process of managing software by ensuring that what you develop and test in one environment, will work reliably in another.



Get to know why and how it replace virtual machines


Docker containers replace virtual machines by virtualizing the operating system instead of the hardware. This means that Docker containers are more lightweight and efficient than virtual machines, and they can be used to run multiple applications on a single host machine.


Traditional virtual machines create a complete operating system environment for each virtual machine, including its own kernel, libraries, and applications. This means that each virtual machine requires its own share of the host machine's resources, such as CPU, memory, and disk space.


Docker containers, on the other hand, share the host machine's kernel and libraries. This means that Docker containers are much smaller and more efficient than virtual machines. Docker containers can also be started up and stopped much faster than virtual machines.

Docker containers are tied to the underlying operating system, so you cannot run Windows containers on Linux systems or vice versa.





How to Install docker on Linux

To install Docker on Debian-based Linux systems, run the following command:


sudo apt install docker.io -y





If Docker is not enabled or not active after installation, run the following commands:

sudo systemctl enable docker


sudo systemctl start docker



Installing images


After installing Docker, you can start installing images by pulling and running them as containers. To try out the pre-built penetration testing Kali OS images from Offensive Security, download them from the official site kali.org. Once you have chosen a containerized application, you will be redirected to Docker Hub, where you can also search for other images.




To pull an image from Docker Hub, you can use the docker pull command with the image name.

sudo docker pull kalilinux/kali-rolling





To list all pulled images, run the following command:

sudo docker images





It's time to deploy our container using the command:


sudo docker run -d -t --name kali kalilinux/kali-rolling




Where:

-d Run the container in detached mode. This means that the container will run in the background, even if you exit the terminal window.


-t Attach an interactive terminal to the container. This is useful for running commands inside the container.


--name Set a custom name for the container.


kalilinux/kali-rolling The name of the Docker image to run as a container.

To list all the running containers, run the following command:

sudo docker ps





To log in to our container, we can use the “docker exec”command:


sudo docker exec -it kali bash




After logging in, you may realize that there are no hacking tools installed in the Kali container. This is because the container is very lightweight and doesn't come with any preinstalled tools. However, you can easily install any required tools or toolboxes using the apt package manager.


Summary


Docker is becoming very popular among the hacker and cybersecurity industry due to the fact that it enables lightweight virtualization and comes with all the code, libraries and dependencies you need to run the application. This is one more tool in your toolbox that will help you along your path to becoming a Cyberwarrior!

4,731 views

Recent Posts

See All
bottom of page