Kali Linux is a powerful Linux distribution used by the developers and security professionals to perform ethical hacking and penetration testing. The advantage of the Kali Linux operating system over other Linux operating systems is that it can be installed on a wide range of devices and platforms. Among those platforms, running Kali Linux on docker is a convenient and flexible way to use the operating system. The main reason behind this is that users can change and alter the prebuilt Kali Linux docker images and customize the operating system according to their choices. Further, with docker, you can also run Kali Linux online in the browser, which is quite useful for those who don’t have good system specifications for running Kali Linux operating system.
Follow this guide to learn:
How to Run Kali Linux Online in Browser with Docker
Before running Kali Linux online in a browser with docker, you must ensure docker is installed on your system. If you are using a Windows system, you can install Docker Desktop application (Windows) to use docker commands on Command Prompt or PowerShell. The Linux users can install docker on their systems by installing Docker Desktop application (Linux) or from the apt repository using the following command:
The Mac users can also install Docker Desktop application (Mac) on their systems or if they don’t like, they can directly use the brew command to install docker:
However, Mac users also need to install additional tools like hyperkit and minikube from the brew command given below:
The reason for installing these tools is to ensure that docker commands can be run successfully on a Mac system.
After installing the docker on your system, use the following steps to run Kali Linux online in the browser with the docker:
Step 1: Check Docker Installation
First, ensure docker is installed on your system, it can be done by using the following command:
Step 2: Run Docker on a System
If you have installed a Docker Desktop application on a Windows, Mac or Linux system, you must run the application on your desktop. However, if you have installed docker on Mac from the brew install command, you have to start minikube first on Mac using the below-given command:
Then tell docker cli to talk with the minikube’s VM on Mac through the provided command:
The purpose of running the above commands is to help you successfully run the docker commands on Mac without an error.
Step 3: Pull the Kali Linux Docker Image
Now, pull the latest Kali Linux docker image on your system from the below-given command:
Note: We have run the docker commands on Windows system, the same commands can be run on Linux or Mac with sudo privileges.
Step 4: Start a New Docker Container
Next, you must start a new docker container from the previously pulled Kali Linux image using the following command:
Here is the breakdown of the above docker command:
- –rm flag tells docker to remove the container once it exists.
- –it command will create an interactive terminal session attached to the container.
- -p 9020:8080 -p 9021:5900 will map ports on your host machine to ports inside your docker container. -p 9020:8080 will allow you to access the VNC desktop of the Kali Linux container on your browser. The -p 9021:5900 will allow you to connect to a VNC server using the VNC client.
- iphoneintosh/kali-docker:latest is the specific docker image used in this process.
Once you run the above command, it will open the Kali Linux shell on your console. It will also provide you with the browser link:
Step 5: Run Kali Linux in Browser
Copy the link provided in the output of the above-given command. Then open your browser and navigate to that link. Click on the Advanced button to ensure the link you are going to visit is protected:
Then force the browser to navigate to that link:
Select the Connect button:
Type it the default password “changeme” in the Password box and click on the Send Password button:
Once done, Kali Linux desktop will open on your browser:
You will then be able to use the Kali Linux desktop by running applications or executing commands on the terminal right from your browser.
How to Resume Kali Linux Docker Container
In case you have restarted your system for some reason, you can resume your Kali Linux docker container again by using the following steps:
Step 1: Check for Docker Container ID
First, use the docker ps command on the terminal where you have run the Kali Linux docker image:
Step 2: Start Docker Container
Now, use the docker start command with the CONTAINER ID to start that specific container on the system:
Step 3: Resume Docker Container
Then resume the docker container using the docker attach command with the CONTAINER ID:
This will resume the container, and you can then navigate to the browser and access the Kali Linux system.
Note: You can resume your docker container directly from the Docker Desktop Application by navigating towards the images section and click on the Play button:
Then use the Run button to run the container on your system:
Conclusion
Running Kali Linux online in a browser with docker is a useful task that prevents users from installing a full Kali Linux desktop environment on their computers. To run Kali Linux online in the browser with docker, you must install docker on your system. After the docker installation, you can pull the Kali Linux docker image and start the docker container to enter into the Kali Linux system. Then open your system browser where you have run the docker commands and access the Kali Linux system using the URL that includes the localhost, IP address and the desired port number.
By day, I am an engineer and researcher, building bridges and figuring out how the universe works. But when the clock strikes five, I turn into a wordsmith!
I write about my adventures on my blog, sharing tips and tricks to help others join the tech fun. I have worked on Raspberry Pi, Ubuntu, Debian, and Laptops. Right now, I have accepted the challenge of working on the Kali Linux system, and with my vast expertise in Linux systems, I will help users overcome the challenges through my blogs.