Docker Compose is a tool that allows to define and run multi-container Docker applications. YAML file is used to define and configure services. All these services are started with single command.
This tutorial shows how to install Docker Compose on Ubuntu 20.04.
Make sure you have installed Docker. You can read post how to install it.
Install Docker Compose
Download binary file from releases page of the Docker Compose repository:
sudo curl -Lo /usr/local/bin/docker-compose https://github.com/docker/compose/releases/latest/download/docker-compose-Linux-x86_64
Assign executable permissions to the downloaded binary file:
sudo chmod a+x /usr/local/bin/docker-compose
You can check the Docker Compose version:
Testing Docker Compose
To test that Docker Compose successfully installed, you can run the
hello-world image with Docker Compose.
Create a new directory for the project:
Go to directory:
Create a YAML configuration file:
Add the following content to a file:
version: '3.8' services: hello-world: image: hello-world:latest
Launch the container using the following command:
Docker Compose downloads a test image and runs it in a container. In this case,
hello-world image is used, so above command prints message and exits.
Uninstall Docker Compose
If you want to completely remove Docker Compose, just delete the binary file:
sudo rm -rf /usr/local/bin/docker-compose