# Installing Docker on Kali Linux


So you want to start using Docker on your Kali Linux install?

Great choice!

Containerization with Docker is a hugely useful skill that will allow you to easily run and manage software in standardized units called containers.

## Why Use Docker?

Docker provides some nice benefits:

- **Portability** - Docker containers can run exactly the same on any platform or cloud provider, from your laptop to large-scale deployments. No more "but it works on my machine!" issues.
- **Lightweight** - Containers share the host system kernel and don't need a full OS, allowing you to run more apps on the same hardware.
- **Safety** - Applications are isolated and unable to mess up the host or other containers.
- **Speed** - No need to provision entire virtual machines, just spin up containers in seconds.

This makes Docker perfect for things like deploying web apps, databases, game servers, and more. It's universal, lightweight, and easy to use.

## Prerequisites

Before installing Docker, you'll need:

- Kali Linux (obviously)
- A non-root user account with `sudo` privileges
- Internet connection

Docker needs the root account to manage background processes, so we'll set up Docker to use `sudo`.

## Install Docker Engine

Here we go, let's get Docker up and running on Kali:

1. Update your package list:

   ```bash
   sudo apt update
   ```

2. Install the dependencies required for adding Docker's repository:

   ```bash
   sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
   ```

3. Add Docker's GPG key:

   ```bash
   curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
   ```

4. Add the Docker repository to APT sources:

   ```bash
   echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
   ```

5. Update packages again:

   ```bash
   sudo apt update
   ```

6. Install the latest Docker version and containerd (a Docker runtime):

   ```bash
   sudo apt install docker-ce docker-ce-cli containerd.io
   ```

That's it, Docker should now be installed and ready to use! The Docker daemon will start automatically on boot.

## Managing Docker Service

To start, stop, or check the status of Docker:

```bash
sudo service docker {start|stop|status}
```

Adding yourself to the `docker` group will allow managing Docker without `sudo`:

```bash
sudo usermod -aG docker ${USER}
```

Log out and back in for this to take effect.

## Hello World

You can verify it's working by running the classic Docker Hello World container:

```bash
docker container run hello-world
```

This should download the tiny hello world image and output some text showing it worked properly.

%[https://developnsolve.com/how-to-install-the-tree-command-on-linux]

## Going Further

And that's it. Docker is installed and you have an idea of managing the service and containers.

Some next things to explore:

- Docker CLI - Tons of commands to build, run, and manage containers and images
- Docker Compose - Easily define and run multi-container apps
- Dockerfile - Build custom images with this DSL
- Docker Hub - Download pre-made images from this registry

The possibilities are endless with Docker. You now have the power to containerize anything and keep exploring.

