Skip to content
DevOps AI ToolKit
Newsletter

Kali Linux on Docker · Part 3 of 16

Installing Kali Tools Inside a Container

Difficulty: Beginner ~12 min Part 3/16
Prerequisites: Kali Linux fundamentalsBasic Docker knowledge
Series progress3 / 16
Series curriculum (16 lessons)

The official kali-rolling Docker image is intentionally lean. Unlike a full Kali desktop install that ships thousands of packages, the base container gives you a minimal Debian-derived system with apt and little else. That is a feature, not a limitation: you get to decide exactly which tools live in your environment. In this lesson you will install a small, curated toolkit and learn a principle that keeps your images fast, small, and secure.

Why the Base Image Is Minimal

When you pull and run kali-rolling, you are not getting the “everything” metapackage that a bare-metal Kali install includes. You get the plumbing — the package manager, a shell, and core libraries — so that the image stays small enough to pull quickly and rebuild often.

That means your first job inside a fresh container is usually to add the specific tools your task requires. Start a container to work in:

docker run --rm -it kalilinux/kali-rolling
  • --rm removes the container automatically when you exit, so you do not accumulate stopped containers.
  • -i keeps STDIN open so you can type commands interactively.
  • -t allocates a pseudo-TTY so the shell behaves like a normal terminal (prompts, colors, line editing).

🛠️ DevOps Perspective — A minimal base is exactly what you want for a disposable troubleshooting environment. You add only what a given task needs, verify your fix, and throw the container away. Reproducibility comes from writing down which tools you installed, not from carrying a bloated image everywhere.

Update the Package Index First

Before installing anything, refresh the local package index so apt knows what is available and where to fetch it:

apt update

This downloads the latest package lists from Kali’s mirrors. It does not upgrade or install anything — it just updates apt’s catalog. The base image ships with a stale or empty index, so skipping this step is the number-one reason installs fail with “Unable to locate package.”

💡 Note — Inside a container you are typically already root, so you will not need sudo. On a normal host you would prefix these commands with sudo.

Install a Curated Toolkit

Now install a focused set of packages that covers the everyday DevOps troubleshooting workflow — DNS, connectivity, port scanning, packet inspection, TLS, and JSON handling:

apt install -y \
    curl \
    dnsutils \
    iproute2 \
    iputils-ping \
    nmap \
    tcpdump \
    openssl \
    jq
  • -y answers “yes” to the confirmation prompt automatically, which is what you want in a container or a scripted build.
  • The trailing backslashes (\) continue one logical command across several lines so the list stays readable.

Here is what each package buys you:

  • curl — Make HTTP/HTTPS requests to APIs and health endpoints, inspect status codes and headers, and reproduce what a client sees. Your primary tool for HTTP and API troubleshooting.
  • dnsutils — Provides dig and nslookup for resolving names, querying specific record types, and confirming which resolver actually answered. Essential when “it works by IP but not by name.”
  • iproute2 — The modern ip command suite (ip addr, ip route, ip neigh). Shows the container’s addresses, routing table, and neighbor cache — how the container sees the network.
  • iputils-ping — The ping command, for the most basic reachability check: can this container reach that host at all, and what is the round-trip latency?
  • nmap — Port and service discovery. Confirm which ports a service is actually listening on and what it reports about itself. (Only against systems you own or are authorized to test — more on that below.)
  • tcpdump — Capture and inspect packets on the wire to see exactly what is being sent and received when higher-level tools disagree about what “should” be happening.
  • openssl — Inspect TLS certificates, check expiry and chains, and test handshakes against an endpoint. Your tool for “why is this HTTPS connection failing?”
  • jq — Parse and filter JSON on the command line, which makes curl output from APIs actually readable and scriptable.

🧪 Try It — After the install finishes, verify a couple of tools resolve and run: dig +short example.com and curl -sI https://example.com. If both return output, your toolkit is wired up correctly. Only scan, inspect, or test systems you own or have explicit permission to assessexample.com is a benign, publicly documented endpoint intended for this kind of check.

The Principle: Install What Your Workflow Needs, Not Every Tool Kali Provides

It is tempting to install the giant kali-linux-everything metapackage “just in case.” Resist that. The guiding rule for containers is:

Install the tools your workflow needs, not every tool Kali provides.

Here is why a curated set beats the kitchen sink:

  • Image size — The everything metapackage is many gigabytes. A curated toolkit is tens to a couple hundred megabytes on top of the base. Smaller images pull faster, push faster, and cost less to store in a registry.
  • Attack surface — Every installed binary is more code that could contain a vulnerability or be abused if the container is compromised. Fewer packages means fewer things to patch and fewer things an attacker can reach for.
  • Build speed — Installing eight packages takes seconds; installing thousands takes many minutes and re-downloads on every cache miss. Fast builds mean you actually iterate instead of waiting.
  • Maintenance — A small, explicit list is easy to audit and reason about. You know exactly why each tool is present, so upgrades and reviews stay manageable.
  • Purpose-built containers — The container model rewards single-purpose environments: a DNS-debugging image, a TLS-inspection image, a packet-capture image. Each carries only what its job needs, which is easier to reason about than one image that does everything.

🔐 Security Note — A smaller image is a smaller attack surface. Every package you do not install is a class of vulnerabilities you never have to track or patch. Treat “what can I leave out?” as a security decision, not just a size optimization — this is the least-privilege mindset applied to software inventory.

🏭 Why This Matters in Production — In CI/CD and on shared hosts, images are pulled constantly and scanned for CVEs. A lean, purpose-built Kali image passes vulnerability scans faster, downloads faster on every pipeline run, and gives auditors a short, defensible list of exactly why each tool is present.

These Installs Do Not Survive --rm

Here is a catch that trips up newcomers. Everything you just installed lives only in this container’s writable layer. Because you started it with --rm, the moment you exit the shell, the container — and every package you added — is deleted:

exit
# container is gone, and so are curl, nmap, tcpdump, ...

Run a fresh kalilinux/kali-rolling again and you are back to the minimal base with none of your tools. Re-running apt update && apt install every single time is slow and easy to forget.

The fix is to bake your curated toolkit into a custom image once, so every container starts ready to work. That is exactly what the next lesson covers: writing a small Dockerfile that installs these packages at build time.

🛠️ DevOps Perspective — Installing interactively is great for exploring. But the moment you find a toolkit you reuse, capture it in a Dockerfile. That turns “I think I ran some apt commands” into a reproducible, version-controlled artifact your whole team can pull.

Common Problems

Symptom: E: Unable to locate package <name>

The package name is correct but apt cannot find it. Almost always this means the package index is empty or stale. Diagnostic steps:

  1. Run apt update first, then retry the install. A fresh container has no usable index until you do this.
  2. Double-check the package name (for example, dig lives in dnsutils, not a package called dig).
  3. If apt update itself errors, the container cannot reach the mirrors — see the next problem.

Symptom: apt update hangs or fails with “Could not resolve” / “Temporary failure resolving”

This is a networking or DNS problem, not a package problem. The container cannot reach Kali’s mirrors because name resolution or outbound connectivity is broken. Quick diagnostics:

  1. ping -c1 1.1.1.1 — if the IP is reachable but names are not, DNS is the issue.
  2. cat /etc/resolv.conf — confirm the container has a resolver configured.
  3. Container networking and DNS have their own moving parts. Work through them in the dedicated Docker networking lesson, which explains how a container gets its address, routes, and resolver.

🔎 Troubleshooting Tip — Think in terms of expected state versus observed state. You expect apt to reach a mirror by name. If the observed result is “cannot resolve,” isolate the layer: name resolution (DNS), then IP reachability (routing/connectivity), then the mirror itself. Testing each layer in order tells you exactly where the break is instead of guessing.

Where to Go Next

What You Learned

  • The kali-rolling base image is intentionally minimal, so you add only the tools a task needs.
  • Always run apt update before apt install so the package index is current, and use -y for non-interactive installs.
  • A curated toolkit (curl, dnsutils, iproute2, iputils-ping, nmap, tcpdump, openssl, jq) covers everyday DNS, connectivity, scanning, packet, TLS, and JSON troubleshooting.
  • Install the tools your workflow needs, not every tool Kali provides — smaller images mean faster builds, easier maintenance, and less attack surface.
  • Packages installed in a --rm container vanish on exit, which is the motivation for building a custom image next.

Affiliate Disclosure: Some links on this page are affiliate links. If you purchase through one of these links, DevOps AI Toolkit may earn a commission at no additional cost to you. See our affiliate disclosure.

← Back to Kali Linux on Docker Back to Kali Linux

Related on DevOps AI Toolkit