A streamlined Docker setup for Kali Linux containers with pre-configured pentesting tools, oh-my-zsh, and powerlevel10k theme.
# Clone the repository
git clone https://github.com/DejaToris/kali-docker-setup.git
cd kali-docker-setup
# Make scripts executable
chmod +x *.sh
# First, create the baseline image (only needed once)
./create-baseline.sh
# Then quickly deploy containers
./quick-deploy.sh <container_name> <port>
./quick-deploy.sh kali-htb 4444# Start the container
docker-compose up -d
# Access the container
docker-compose exec custom-kali zsh# Build the image
docker build -t custom-kali .
# Run the container
docker run -d \
--name custom-kali \
--privileged \
--cgroupns=host \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
-v ~/kali-docker-shares/ovpn-configs:/ovpn-configs:ro \
-v ~/kali-docker-shares/scripts:/host-scripts:rw \
--tmpfs /tmp \
--tmpfs /run \
--tmpfs /run/lock \
-p 4444:22 \
custom-kaliThis project provides three main scripts for managing Kali containers:
Creates a baseline Docker image with all Kali packages installed. This is a one-time setup that takes significant time but enables fast container creation later.
./create-baseline.shQuickly creates new containers from the baseline image. Much faster than building from scratch.
./quick-deploy.sh <container_name> <port>
./quick-deploy.sh kali-htb 4444
./quick-deploy.sh kali-thm 5555Helps manage baseline images and containers with various utility commands:
./kali-manager.sh status # Show baseline and container status
./kali-manager.sh list # List all containers
./kali-manager.sh ports # Show port usage
./kali-manager.sh clean-containers # Remove stopped containers
./kali-manager.sh clean-baseline # Remove baseline image
./kali-manager.sh clean-old-baselines # Remove old baseline images (keep latest)The scripts automatically create these directories:
~/kali-docker-shares/ovpn-configs # For VPN configuration files
~/kali-docker-shares/scripts # For custom scripts- Place your
.ovpnfiles in~/kali-docker-shares/ovpn-configs/ - They'll be available in
/ovpn-configs/inside the container - Example:
openvpn /ovpn-configs/htb-lab.ovpn
- Place executable scripts in
~/kali-docker-shares/scripts/ - They'll be automatically added to PATH inside the container
- Example: Create
~/kali-docker-shares/scripts/my-enum.shand it'll be available asmy-enum.shfrom anywhere in the container
ssh root@localhost -p <port>
# Password: kali
# Replace <port> with the port you specified when creating the containerdocker exec -it custom-kali zsh# Start Metasploit (database already configured)
msfconsole
# Check database status
msfdb status# Connect to HTB/THM/etc
openvpn /ovpn-configs/your-config.ovpn# SecLists are installed at /usr/share/seclists/
ls /usr/share/seclists/
# Common wordlists
/usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt
/usr/share/seclists/Passwords/Common-Credentials/10-million-password-list-top-1000.txt
/usr/share/seclists/Usernames/Names/names.txt
# Example usage with gobuster
gobuster dir -u http://target.com -w /usr/share/seclists/Discovery/Web-Content/common.txt
# Example usage with hydra
hydra -L /usr/share/seclists/Usernames/top-usernames-shortlist.txt \
-P /usr/share/seclists/Passwords/Common-Credentials/top-passwords-shortlist.txt \
ssh://target.com# Powerlevel10k theme is pre-configured with:
# - Directory and git status in prompt
# - Command execution time
# - Syntax highlighting and auto-suggestions
# - Custom aliases for pentesting
# Pre-configured aliases:
ll # List files with details
wordlists # Browse seclists wordlists
weblist # Browse web content wordlists
nse # Search nmap scripts
myip # Get external IP
ports # Show listening ports
# Pre-configured functions:
quickscan <target> # Fast nmap scan
dirb_common <url> # Directory enumeration
hydra_ssh <target> <user> # SSH password attack
serve [port] # Quick HTTP server# Stop container
docker stop custom-kali
# Start container
docker start custom-kali
# Restart container
docker restart custom-kali
# View logs
docker logs custom-kali
# Remove container
docker rm custom-kali
# Rebuild image
docker build -t custom-kali . --no-cacheEdit the Dockerfile and add packages to the apt-get install command:
RUN apt-get install -y \
your-additional-tool \
another-toolModify the volume mounts in:
quick-deploy.sh(updateHOST_OVPN_DIRandHOST_SCRIPTS_DIR)docker-compose.yml(update the volumes section)
Add port mappings in the docker run command or docker-compose.yml:
-p HOST_PORT:CONTAINER_PORT# Check logs
docker logs <container-name>
# Verify systemd is working
docker exec -it <container-name> systemctl status# Reinitialize database
docker exec -it <container-name> msfdb reinit# Check if SSH is running
docker exec -it <container-name> systemctl status ssh
# Restart SSH
docker exec -it <container-name> systemctl restart ssh# Make scripts executable
chmod +x ~/kali-docker-shares/scripts/your-script.shThe typical workflow for using this project:
- One-time setup: Run
./create-baseline.shto build the baseline image with all tools - Deploy containers: Use
./quick-deploy.sh <name> <port>to quickly create containers - Manage containers: Use
./kali-manager.shto check status, clean up, etc. - Reuse baseline: The baseline image can be reused to create multiple containers quickly
- The container runs with
--privilegedfor systemd functionality - Root password is set to "kali" for SSH access
- Only use in trusted/isolated environments
- Consider changing the SSH password for production use
- Port conflicts are automatically detected to prevent accidental exposure
Create specialized baselines by modifying the Dockerfile:
# Create a web-focused baseline
# Edit Dockerfile to add more web tools, then:
./create-baseline.sh
docker tag kali-baseline:latest kali-web-baseline:latest
# Create containers from specific baseline using manual docker commands
docker run -d --name web-container kali-web-baseline:latest# Add your tools to the scripts directory
echo '#!/bin/bash\nnmap -sS -O $1' > ~/kali-docker-shares/scripts/quick-scan
chmod +x ~/kali-docker-shares/scripts/quick-scan
# Now available in all containers as: quick-scan <target>| Script | Purpose | Usage |
|---|---|---|
create-baseline.sh |
Build baseline image with all tools (slow, one-time) | ./create-baseline.sh |
quick-deploy.sh |
Create containers quickly from baseline | ./quick-deploy.sh <name> <port> |
kali-manager.sh |
Manage containers and baseline images | ./kali-manager.sh [status|list|ports|clean-containers|clean-baseline|clean-old-baselines] |