Setting up a practice lab for penetration testing techniques - Creating isolated environments for exploit development and testing - Building vulnerable application targets for training - Testing tools against known-vulnerable configurations - User says "lab", "docker lab.
Setting up a practice lab for penetration testing techniques - Creating isolated environments for exploit development and testing - Building vulnerable application targets for training - Testing tools against known-vulnerable configurations - User says "lab", "docker lab.
Disposable Testing — Spin up and tear down test environments without affecting host system or production infrastructure
Tool Validation — Test new security tools and exploits in a known, controlled environment before engagement use
Activation
Setting up a practice lab for penetration testing techniques
Creating isolated environments for exploit development and testing
Building vulnerable application targets for training
Testing tools against known-vulnerable configurations
User says "lab", "docker lab", "test environment", "practice target"
Core Principle
Never test attack techniques against systems you don't own or have explicit authorization to test. Docker labs provide safe, legal environments for security practice and tool validation.
All lab environments bind to 127.0.0.1 only — never expose on public interfaces.
Practice targets: Full OWASP Top 10 coverage, API security, XSS, JWT attacks, access control
Pattern 2: Network Pentest Lab
Multi-Service Network Lab
# docker-compose.network-lab.ymlversion:'3.8'services:# Target: Vulnerable SSH servertarget-ssh:image:rastasheep/ubuntu-sshd:18.04ports:-"127.0.0.1:2222:22"networks:-lab-net# Target: Vulnerable FTP servertarget-ftp:image:stilliard/pure-ftpd:latestports:-"127.0.0.1:2121:21"-"127.0.0.1:30000-30009:30000-30009"environment:-PUBLICHOST=localhostnetworks:-lab-net# Target: Web server with vulnerabilitiestarget-web:image:php:8.1-apacheports:-"127.0.0.1:8083:80"volumes:-./vulnerable-app:/var/www/htmlnetworks:-lab-net# Attacker machine (Kali tools)attacker:image:kalilinux/kali-rolling:latestnetworks:-lab-netcommand:tail-f/dev/null# Keep alivecap_add:-NET_ADMINnetworks:lab-net:driver:bridgeipam:config:-subnet:172.28.0.0/16
Practice targets: Network enumeration, service identification, SSH brute force, FTP attacks, web app attacks
Pattern 3: Multi-Stage Attack Chain Lab
Simulates a realistic attack chain across multiple vulnerable services:
# docker-compose.attack-chain.ymlversion:'3.8'services:# Stage 1: External-facing web app (initial access)web-frontend:build:./scenarios/web-frontendports:-"127.0.0.1:9000:80"networks:-dmzdepends_on:-web-api# Stage 2: Internal API (lateral movement target)web-api:build:./scenarios/web-apiports:-"127.0.0.1:9001:8080"networks:-dmz-internalenvironment:-DB_HOST=database-DB_PASS=weakpassword123# Stage 3: Database (data target)database:image:mysql:5.7networks:-internalenvironment:-MYSQL_ROOT_PASSWORD=weakpassword123-MYSQL_DATABASE=secretsvolumes:-./scenarios/db-init:/docker-entrypoint-initdb.d# Stage 4: Internal admin panel (privilege escalation)admin-panel:build:./scenarios/admin-panelnetworks:-internalenvironment:-ADMIN_USER=admin-ADMIN_PASS=admin123networks:dmz:driver:bridgeipam:config:-subnet:172.29.0.0/16internal:driver:bridgeipam:config:-subnet:172.30.0.0/16internal:true# No external access
Practice targets: Multi-stage exploitation, lateral movement, privilege escalation, data exfiltration
Pattern 4: Disposable Testing
Quick spin-up for single-tool testing:
# One-liner for testing a specific tool against a specific image
docker run --rm -it --network=host kalilinux/kali-rolling:latest \
bash -c "apt update && apt install -y nmap && nmap -sV 127.0.0.1"# Temporary vulnerable target
docker run --rm -d -p 127.0.0.1:9999:80 vulnerables/web-dvwa:latest
# Test and destroy
docker stop $(docker ps -q --filter publish=9999)
Rules:
Always use --rm for auto-cleanup
Always bind to 127.0.0.1
Never persist sensitive data from test containers
Pattern 5: Tool Testing Environment
Validate tool behavior against known-vulnerable targets:
# docker-compose.tool-test.ymlversion:'3.8'services:# Known-vulnerable target for tool calibrationtarget:image:vulnerables/web-dvwa:latestports:-"127.0.0.1:9090:80"# Tool under testtool-test:image:kalilinux/kali-rolling:latestnetwork_mode:"host"command:tail-f/dev/nullvolumes:-./test-results:/results
Safety Rules
Bind to localhost only — All port mappings use 127.0.0.1:port:container_port
No persistent sensitive data — Use --rm or anonymous volumes
Isolated networks — Lab networks should not overlap with production
Resource limits — Set memory and CPU limits to prevent runaway containers
Cleanup after use — docker compose down -v to remove containers and volumes
# Full cleanup
docker compose -f docker-compose.lab.yml down -v --rmi local
docker system prune -f
Integration with Other Skills
Skill
Docker Pattern
Application
web-sqli
Pattern 1 (DVWA/SQLi-Labs)
Practice SQL injection techniques safely
web-xss
Pattern 1 (DVWA/Juice Shop)
Practice XSS payload crafting
web-auth-bypass
Pattern 1 (Juice Shop)
Practice authentication attack techniques
network-pentest
Pattern 2 (Network Lab)
Practice network enumeration and service exploitation
post-exploitation
Pattern 3 (Attack Chain)
Practice lateral movement and privilege escalation
verification-loop
Pattern 5 (Tool Test)
Verify tool accuracy against known vulnerabilities
autonomous-loops
Pattern 4 (Disposable)
Quick test loops against disposable targets
terminal-ops
All patterns
Evidence protocol for all lab activities
Quick Start
# Start DVWA labcd ~/.openclaw/workspace-kali-claw/skills/docker-patterns/
docker compose -f configs/docker-compose.dvwa.yml up -d
# Access DVWA# http://127.0.0.1:8080 (admin/password)# Stop and clean up
docker compose -f configs/docker-compose.dvwa.yml down -v
Detection Methods
Docker Daemon Audit
Anomalous docker commands: docker run --privileged, docker run -v /:/host from non-CI sources.
Rationale: Lab environments follow a strict lifecycle — each phase must complete before the next begins, and cleanup is mandatory
Integration: All security skills that need practice environments (web-sqli, web-xss, network-pentest, post-exploitation), terminal-ops (evidence capture), safety-guard (localhost-only enforcement)