Install Docker in Kali Linux and Run Other OS

Docker is a amazing system to run other Operating System in our primary OS Kali Linux. The system is not similar with VMWare or Virtual Box. Unlike the virtual machines, docker is a containers based system. VMWare runs the full size operating system over our primary system so it consumes lots of our hardware resources. In this detailed tutorial we learn how we can install and use docker in our Kali Linux computer.
Install Docker in Kali Linux and Run Other OS

Docker can replace the virtual machines in future. For being a container based docker can run application using it's own engine. It is isolated but share OS and where appropriate, bin/libraries to know about docker we can check this article.

Now we learn how we can install docker in our Kali Linux machine.


For the newer versions of systems like Kali Linux 2020 versions doesn't need lengthy process. There we can use one simple command to install docker:
sudo apt-get install -y
This command  will install docker on our system.

Docker installation Older Method

If we are in any older system then we need to follow this guide to install docker on our machine.
First we need to add docker gpg key. We can do it by using following command:-

curl -fsSL | sudo apt-key add -
If it ask for the sudo password then we provide it and press Enter. Basically it will add Debian Linux's gpg key in our Kali Linux and will show us "OK" if the process become successful as following screenshot.

gpg key adding for docker
If we want to use docker we need to add it's repository in our system. So we open the sources.list file in our /etc.apt/sources.list on mousepad text editor by using following command:

sudo mousepad /etc/apt/sources.list
changing sources file

Here we add a line.
deb [arch=amd64] buster stable
This is shown in following screenshot.

added repository for docker

Then we save and close it. Now we update our system using following command:

sudo apt-get update
This update command will update our docker repository as per following screenshot.

updating docker repository

Now we can simply install the docker by applying following command:

sudo apt-get install docker-ce
This command will install the docker system. The screenshot is following.

installing docker-ce

This process will take some time depending on our internet speed.

After installation we can check docker's help menu by using simply add docker command:

docker help menu
In the above screenshot we can see how we can use docker.

Using Docker Services

Let's start the docker service by using following command:

sudo service docker start
Now we check that our installation is correct is correct or not by using following command:

docker run hello-world
Running this command will check for hello world in our local ant there is nothing then it download hello world from docker's repository, then show us a hello message as shown in following screenshot:

running docker

If hello-world works then we have successfully installed docker, now we can install other OS images using docker. We can see the list of available official images in docker's official website.

We can pull images from the website by running command:

docker pull image-name
Then we can run it. We also can pull and run images directly.

For an example we directly pull and run Ubuntu in our Kali Linux system. To do that use use following command:-

sudo docker run -it ubuntu bash
installing Ubuntu using docker
Installing Ububtu in our Kali Linux using docker
In the above screenshot we can see docker is downloading Ubuntu which size is 26 MB. Only 26 MB of Ubuntu yes we are not kidding. Isn't it really cool ?

Let the process finish. This process will take some time depending on our internet speed, and will automatically run Ubuntu as shown in following screenshot.
installing Ubuntu in Kali Linux

Now wee are in Ubuntu terminal. Let's check it by applying following command:

cat /etc/os-relese
In the following screenshot we can see that we are not in Kali Linux and we are in the Ubuntu 18.
Ubuntu in docker
Ubuntu in Kali Linux using Docker
This is how we can run other OS like debian, fedora and even Windows in our Kali Linux with very little image file size using docker.

We can check the docker service status with the help of following command:

sudo service docker status
To see the locally saved docker images we simply run:

docker images

This is how we can install and use docker in our Kali Linux. If we miss anything or got some issue in docker comment down, we always happy to help. Follow our blog for more tutorials and follow us on Twitter and Medium for quick updates.

No comments:

Please do not spam here. It is comment box not a spambox. Promotional links are not allowed.

Powered by Blogger.