Often, docker images will be published in GitHub using a file called docker-compose.yml or compose.yml. With Docker Compose, we can create yaml (.yml) configuration files that define everything we’d like running within a container, including options like:
- Base container to run
- Ports to map
- Volumes to map
- Programs to install
- Configuration files to include
- Other specific configuration options (Discussed Later)
Why? Remember command line parameters can be difficult!
For example:
*-p 80:80 -v /home/student/webpage:/var/www/html*
can be difficult to recall, and typos can cause things to break. Creating a file with all configuration options saved in an easier-to-manage format is better. Once we have everything set up correctly, we can use this file to start/run containers with complex configurations easily.
Install docker-compose
- Note: This package may not be available, and the command might fail!
- See the Directions Below for alternate installation directions.
apt install docker-compose
If docker-compose isn’t installable via the *apt* package manager, we can install it manually like this.
sudo curl -L "<https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$>(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
You can verify that docker-compose has been installed with this command:
docker-compose --version