Installing Docker on Kali Linux can be accomplished through a couple of methods, primarily by installing the docker.io package from Kali's own repositories or by adding Docker's official repository and installing docker-ce. Here is a comprehensive guide to get Docker up and running on your Kali Linux system.
Method 1: Installing docker.io from Kali Repositories (Easiest)
This is the most straightforward method as it uses the package available in the official Kali Linux repositories.
1. Update your package list:
Open your terminal and run the following command to ensure your package list is up-to-date:
sudo apt update
2. Install the docker.io package:
Next, install the docker.io package with this command:
sudo apt install -y docker.io
3. Enable and start the Docker service:
Once the installation is complete, you need to enable and start the Docker service to have it run automatically at boot:
sudo systemctl enable docker --now
Method 2: Installing docker-ce from the Official Docker Repository
This method involves adding Docker's official repository, which might provide a more recent version of Docker Engine.
1. Update your package list and install dependencies:
First, update your package list and install the necessary packages to allow apt to use a repository over HTTPS.
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
2. Add Docker’s official GPG key:
To ensure the authenticity of the Docker packages, add Docker's official GPG key.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
3. Set up the stable repository:
Since Kali Linux is based on Debian, you will need to add the Docker repository for the corresponding Debian version. At the time of writing, Kali is based on Debian "bookworm".
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
4. Install Docker Engine:
Now, update your package list again and install docker-ce.
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
5. Enable and start the Docker service:
Just like with the first method, enable and start the Docker service.
sudo systemctl enable docker --now
Post-installation Steps
Running Docker without sudo
To run Docker commands without having to type sudo every time, you need to add your user to the docker group.
1. Add your user to the docker group:
sudo usermod -aG docker $USER
2. Apply the group changes:
For the new group membership to take effect, you need to either log out and log back in, or you can use the following command:
newgrp docker
Verifying the Installation
You can verify that Docker has been installed correctly by running the "hello-world" container.
docker run hello-world
If the installation was successful, you will see a message indicating that your installation appears to be working correctly. This confirms that you have successfully installed and configured Docker on your Kali Linux system.
Top comments (0)