Kali Linux In a Docker Container


docker pull kalilinux/kali-rolling
docker run -ti kalilinux/kali-rolling /bin/bash

First Things First

apt update
apt dist-upgrade
apt autoremove
apt clean
apt install kali-tools-top10
docker ps -a
CONTAINER ID        IMAGE                         COMMAND             CREATED              STATUS                     PORTS               NAMES
2a08d58bcfa8 kalilinux/kali-rolling "/bin/bash" About a minute ago Exited (0) 2 seconds ago thirsty_snyder
docker commit <CONTAINER ID> my-kali
docker run -ti my-kali /bin/bash

Persistence Strategies

Option 1 — Volumes

  • /root — home dir for root (downloads, notes, source code etc.)
  • /var/lib/postgresql— Postgres database files (used by Metasploit)
docker run -ti --rm --mount src=kali-root,dst=/root --mount src=kali-postgres,dst=/var/lib/postgresql my-kali
  • This will create two volumes named kali-root and kali-postgres — or use existing ones on subsequent runs — and map them to the created container.
  • --rm switch makes Docker delete the container once it stops (i.e. once you exit the shell). This is perfectly fine (and preferred behaviour — you don’t want to waste storage on a bunch of stopped containers) as you have all the components — the image and the two volumes — to recreate it.
docker run -ti --rm --mount type=bind,src=/some/path/kali-root,dst=/root --mount type=bind,src=/some/path/kali-postgres,dst=/var/lib/postgresql my-kali bash

Option 2 — Within the Container

docker ps -a
docker start --attach <CONTAINER ID>

Docker Cleanup

docker container prune




Random rumblings about #InfoSec. The opinions expressed here are my own and not necessarily those of my employer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Fight For The Best Selling eCommerce Platform: Magento Commerce Vs Magento Community

Magento Commerce vs. Magento Community

OutSystems Platform Upgrade 101

7 Best Java Design Pattern Books for Beginners and Experienced Programmers

Python Caches Integers

My second week with Haiku: Lots of hidden gems and pleasant surprises, and some issues

What the Flows: Build an Android app using Flows, Live Data, and MVVM architecture

Spring WebFlux :- Building Reactive Web Services

10 Best Coursera Courses and Certifications to Learn In-demand Skills in 2022

Best Coursera Programs, Coursers, Specialiation and Certification to Join

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Random rumblings about #InfoSec. The opinions expressed here are my own and not necessarily those of my employer.

More from Medium

3 Different Ways To Install Nmap On Linux Mint Or Ubuntu

SSH to Red Hat with Docker

Know Kali Linux — What is Kali Linux [Part 1]

Linux Fundamental Part 1 | TryHackMe