How-To: docker-compose
This year we will be using a lot of docker machines. They are like virtual machines, however slimed down, therefore using less resources and have smaller file sizes. We recommend running docker on your Kali Linux machine (or Debian based distribution), even though it can run on Windows, it can be temperamental at times. Therefore, this is a guide for Linux only.
Installation
Firstly, ensure your system is fully up to date, then install the necessary packages.
|
|
Now all the required software should be downloaded.
Demonstration
Next you will need a docker-compose file - this just instructs docker on how to load the correct image. For this demonstration, we will use the file from the first week.
Below, we firstly create a new folder, download a docker-compose file then run it.
|
|
Finding the Right IP
Normally docker should assign itself to localhost (127.0.0.1), however this is not always the case – just have a look at the output from the docker-start command, and it should show you (see the demo above). To be able to attack all services, to complicate matters, you will have to change this IP – change the end number to a 1. E.g., 192.168.42.4 -> 192.168.42.1
Shutting Down Docker
When you have finished & found all the flags (congratulations) go back to the terminal window running docker – press CTRL + C simultaneously. Sometimes this takes a minute or two – wait until all the machines say ‘done’.
|
|
Troubleshooting/Common Errors
Docker is an amazing piece of software - when it works! Unfortunately, it is prone to errors; here’s how to fix the most common:
- Error -
E: Package 'python3-pip' has no installation candidate
Answer: ensure pip is installedapt install pip
. - Error -
Pool overlaps with other one on this address space
Answer: this means that another docker machine/service on your PC is using the same port. This problem can be solved by turning off said docker machine/service and runningsudo docker network prune
.
General Advice/Tips
- Run the command as sudo.
- Ensure a file named ‘docker-compose.yaml’ exists in your present working directory.
- Restart docker machines -
sudo docker-compose restart
(must be run in the same folder as the docker-compose file). - Run
sudo docker-compose kill
(must be run in the same folder as the docker-compose file) to force shutdown a machine. - Try resetting IP addresses -
sudo docker network prune
. - Restart VM – surprising what a reboot can do!
- Google the error or look at the man pages (
man docker-compose
).