Install Docker Compose on Ubuntu 20.04

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.

Prepare environment

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

Assign executable permissions to the downloaded binary file:

sudo chmod a+x /usr/local/bin/docker-compose

You can check the Docker Compose version:

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:

mkdir test

Go to directory:

cd test

Create a YAML configuration file:

nano docker-compose.yml

Add the following content to a file:

version: '3.8'

Launch the container using the following command:

docker-compose up

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

Leave a Comment

Your email address will not be published. Required fields are marked *