← All Video Notes

How to Install Kali Linux in Docker

Watch the video

Running a full Kali Linux VM for the occasional tool or CTF is overkill. If you already run Docker in your home lab, you can get a disposable Kali environment up in under two minutes — and nuke it just as fast when you're done.

Why Docker Instead of a VM?

A VM reserves RAM, disk, and CPU whether you're using it or not, and it takes a snapshot of an entire OS just to run a handful of tools. A container shares the host kernel and only packages the userland tools you actually need, so it starts in seconds and costs you almost nothing at rest. For a "quick nmap scan" or "just need hashcat for five minutes" workflow, that's exactly the trade-off you want.

Step 1: Pull the Official Image

Kali maintains an official Docker image, so there's no sketchy third-party build to trust:

docker pull kalilinux/kali-rolling

Step 2: Run It Interactively

docker run -it --name kali-box kalilinux/kali-rolling /bin/bash
  • -it gives you an interactive TTY attached to the container.
  • --name kali-box makes it easy to reference later instead of a random hash.

You'll land in a bare shell — the rolling image intentionally ships minimal, so you install only what you need.

Step 3: Install the Tools You Actually Use

The base image doesn't include the full kali-linux-default metapackage by design (image size). Grab what you need:

apt update && apt install -y kali-linux-headless
# or, for a specific tool:
apt install -y nmap hashcat john

Step 4: Keep It Around (or Don't)

If you want the container to persist between sessions instead of being wiped on exit:

docker start -ai kali-box

If you'd rather keep things fully disposable — which is the whole point of doing this in Docker — just re-run the docker run command each time and add --rm so it cleans up after itself automatically:

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

A Few Gotchas

  • Networking tools that need raw sockets (like some nmap scan types) require the container to run with extra privileges: add --cap-add=NET_RAW --cap-add=NET_ADMIN rather than reaching for --privileged, which grants far more than you need.
  • GUI tools won't work out of the box. This setup is CLI-only. If you need a desktop environment, you're back to a VM.
  • This isn't a security boundary. Don't treat the container as isolation from anything you don't trust — it shares your host kernel.

Where This Fits in a Home Lab

This pattern — official image, disposable container, --rm by default — is how I run most short-lived tools in the lab now. It keeps the "real" machines clean and means every tool run starts from a known-good state.

If you want the full home lab context this fits into, check out the Home Lab getting-started guide.