Lab
Cybersecurity Lab Setup with Docker
This guide will walk you through setting up a complete cybersecurity lab using Docker. It includes a Kali Linux container, vulnerable web apps, and other services like Metasploitable and DVWA. We'll also cover network isolation, reverse proxy, and logging using the ELK Stack.
1️⃣ Prerequisites: Install Docker & Docker Compose
Install Docker
Ensure that Docker and Docker Compose are installed on your machine. Run the following commands:
Verify your installation by checking the versions:
2️⃣ Set Up a Docker Network
To allow communication between the containers, we need to set up a custom network.
3️⃣ Create a docker-compose.yml
File
docker-compose.yml
FileWe’ll define the services in a docker-compose.yml
file. This file will define containers like Kali Linux, DVWA, Metasploitable, and Juice Shop.
Create a cyberlab
folder and open the docker-compose.yml
file:
Paste the following content into the file:
This setup defines four containers:
Kali Linux for penetration testing.
DVWA (Damn Vulnerable Web App) for web app security practice.
Metasploitable2 for exploiting known vulnerabilities.
OWASP Juice Shop for web application security practice.
4️⃣ Start the Lab
Run the following command to start all containers:
This will start all containers in detached mode.
5️⃣ Access Containers
Here’s how you can access each container:
Kali Linux Shell
To access Kali Linux's interactive shell, run:
DVWA (Damn Vulnerable Web App)
Open http://localhost:8080
in your browser. Login with:
Username:
admin
Password:
password
Metasploitable SSH
SSH into Metasploitable:
Password: msfadmin
OWASP Juice Shop
Open http://localhost:3000
in your browser.
6️⃣ Enhance Your Cybersecurity Lab
Reverse Proxy (Traefik or NGINX)
To manage multiple services via a single entry point, you can use a reverse proxy like Traefik or NGINX.
Using Traefik
Traefik dynamically discovers services via Docker labels. Here's how you can configure it in docker-compose.yml
:
Then, modify your /etc/hosts
file to access dvwa.local
locally:
Start the services:
You can now access DVWA at http://dvwa.local
and the Traefik Dashboard at http://localhost:8080
.
Using NGINX
If you prefer NGINX for reverse proxy, use the following configuration for nginx.conf
:
Run NGINX with:
7️⃣ Set Up Logging & Monitoring with the ELK Stack
To monitor logs from your containers, you can use the ELK Stack (Elasticsearch, Logstash, Kibana).
Add ELK to docker-compose.yml
docker-compose.yml
Configure Logstash (logstash.conf
)
logstash.conf
)Create the logstash.conf
file to specify how logs are processed:
Run the ELK Stack:
Access Kibana
You can access Kibana at http://localhost:5601
and start analyzing logs from your containers.
8️⃣ Set Up a Dedicated Subnet
To enhance your network setup, assign static IP addresses within a custom subnet.
Create a Custom Network
Assign Static IPs in docker-compose.yml
docker-compose.yml
Each container can be assigned a static IP address like this:
9️⃣ Running Vulnerable Containers
Metasploitable 2
Run Metasploitable 2 for vulnerability exploitation:
SSH:
msfadmin:msfadmin
Web:
http://localhost:80
DVWA (Damn Vulnerable Web App)
Run DVWA:
Login:
admin:password
Access:
http://localhost:8080
Conclusion
You now have a fully functional cybersecurity lab with Docker. You can access vulnerable applications like DVWA, Juice Shop, and Metasploitable, all while monitoring logs with ELK and managing services with Traefik or NGINX. Use this environment for penetration testing, vulnerability discovery, and more!
Last updated