
When I first started building labs, I used traditional virtual machines. They worked well, but they could be heavy on memory and slow to start.
Then I started experimenting with Docker.
That changed how I build labs.
Instead of running full operating systems, I could run lightweight containers designed for testing and security practice.
For beginners, Docker can be a great way to build a simple lab without needing a lot of system resources.
What Is a Docker Lab
A Docker lab is a practice environment built using containers instead of virtual machines.
Containers: are isolated environments that package applications and services with everything they need to run.
With Docker, you can spin up vulnerable machines, web applications, databases, and security tools in seconds.
Think of it as building a mini cyber range on your laptop.
Why I Used Docker
I wanted something lighter and faster than traditional virtual machines.
I also liked how easy it was to create, destroy, and rebuild environments.
A Docker lab helped me:
- Practice in an isolated environment
- Deploy vulnerable targets quickly
- Save system resources
- Learn container security
- Experiment with networking
- And most importantly, it made lab setup much easier.
setting up docker lab on windows
The first step was installing Docker.
I downloaded Docker Desktop and verified the installation:
docker --versionThen I checked if Docker was running:
docker psIf Docker responds, you are ready.
Steps I Used to Set Up My Docker Lab on Ubuntu
I built my lab on Ubuntu using Docker, and the setup was straightforward.
1. Update Ubuntu
Before installing anything, I updated the system:
sudo apt update && sudo apt upgrade -y
Install Docker
2. Install Required Packages
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
3. Add Docker’s GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
4. Add the Docker Repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. Install Docker
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io -y
6. Verify Installation
docker --version
Check if Docker is running:
sudo systemctl status docker
Optional Step
7. Run Docker Without sudo
To avoid typing sudo every time:
sudo usermod -aG docker $USER
Log out and log back in after this.
Pull the Lab Machines (windows & linux)
8. Pull Metasploitable
Download the vulnerable target:
docker pull tleemcjr/metasploitable2
9. Start Metasploitable
docker run -d -P --name metasploitable tleemcjr/metasploitable2
Verify it is running:
docker ps
Create the Lab Network
10. Create a Private Network
docker network create pentestlab
11. Connect the Target
docker network connect pentestlab metasploitable
Add the Attacker Machine
12. Pull Kali Linux
Download Kali Linux:
docker pull kalilinux/kali-rolling
13. Launch Kali in the Lab Network
docker run -it --network pentestlab kalilinux/kali-rolling bash
Now you have an attacker container and target container communicating inside the same lab.
Install Tools Inside Kali
14. Install Nmap
Inside the Kali container:
apt update && apt install nmap -y
15. Scan the Target
nmap metasploitable
If you see open services, the lab is working.
Useful Commands I Use
List containers:
docker ps
Stop a container:
docker stop metasploitable
Start it again:
docker start metasploitable
Remove it:
docker rm -f metasploitable
Final Setup
At this point you should have:
Ubuntu host
Docker installed
Private Docker network
Kali Linux attacker container
Metasploitable2 target container