Question

Run Kali in a docker

Hi can I run Kali on docker as I run it in a VM ?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
September 5, 2024
Accepted Answer

Hey there! 👋

Yes, you can run Kali Linux in a Docker container just like you would in a VM, but there are some key differences to be aware of.

Getting Started with Kali Linux Docker Image

To get started, you can pull the official Kali Linux Docker image and run it with the following commands:

docker pull docker.io/kalilinux/kali-rolling
docker run -ti kalilinux/kali-rolling

This will give you a running instance of Kali inside a Docker container. You’ll notice that the prompt looks like this:

┌──(root㉿e4ae79503654)-[/]
└─#

One important thing to note is that systemd is not supported out of the box in Docker. This means you won’t be able to use systemctl without some extra work. If you need systemd, you’ll have to modify the Dockerfile and adjust the docker run flags accordingly.

Installing Metapackages

Also, the image doesn’t come with the default Kali metapackage. You can install it manually by running:

apt update && apt -y install kali-linux-headless

Managing Your Kali Docker Container

If your container exits, don’t worry! You can list all containers, start it again, and reattach like this:

docker container list --all
docker start <CONTAINER_ID>
docker attach <CONTAINER_ID>

You’ll drop back into the same state as before. Just hit return to see the prompt.

Cleaning Up

When you’re done with the container, you can remove it with:

docker rm <CONTAINER_ID>

For more details, check out the official Kali Linux Docker documentation.

Hope this helps! 🚀

- Bobby

KFSys
Site Moderator
Site Moderator badge
September 5, 2024

Heya,

Yes, you can do that.

Pull the Kali Linux Docker Image: Kali provides official Docker images that you can pull from Docker Hub. To download the image, run:

docker pull kalilinux/kali-rolling

This will pull the rolling release version of Kali Linux from Docker Hub.

Run the Kali Linux Docker Container: To start a Kali Linux container interactively, use the following command:

docker run -it kalilinux/kali-rolling /bin/bash

This command will launch a container and give you a bash shell inside it. Once inside, you can use Kali as if it were installed in a traditional environment, but without the overhead of a full VM.

Install Kali Tools: The base Kali image on Docker might not include all the tools you’d expect from a full Kali installation. You can install specific tools or the full Kali toolset by running:

apt update
apt install -y kali-linux-default

This installs the default Kali toolset. You can also install only specific tools as needed.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.