Setup Docker for CTF
Setup Docker for CTF
Overview
I’m using Docker to solve the hackthebox machine. It’s so simple for me to use. Because Ubuntu has been my host machine for several years, and docker supports host networks in linux-based operating systems, but Windows does not. You can also connect the openvpn in docker. If you are using Windows, it will be difficult for you to use because it does not support host networks and you will have some difficulty using the VPN.
Why we need docker for CTF
Docker containers require fewer installations since they share many of their resources with the host system. A container often takes up less space and utilises less RAM and CPU time than a virtual machine. It boot up in a few seconds or less, whereas virtual machines can take several minutes.
Installing the docker for Ubuntu
Setup the repo
Update the apt
package index and install packages to allow apt
to use a repository over HTTPS:
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Use the following command to set up the stable 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
Install Docker Engine
Update the apt
package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
To run Docker without root
Add your user to the docker
group.
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated.
Installation completed now you can run the docker.
reference: https://docs.docker.com/engine/install/ubuntu/
Install the parrot docker image
docker pull parrotsec/security
now you can run the docker container
docker run -it --rm -v /etc/hosts:/etc/hosts -w /root/htb --network host -v $(pwd):/root/htb --cap-add=NET_ADMIN --device /dev/net/tun --name htb parrotsec/security /bin/bash