Chat Zalo Chat Messenger Phone Number Đăng nhập
How to Install and Configure Docker Compose on Ubuntu 20.04

How to Install and Configure Docker Compose on Ubuntu 20.04

Docker Compose is a command-line tool for managing multiple Docker containers. It is a tool for creating isolated containers through the YAML file to modify the services of your application.

On the other hand, Ubuntu 20.04 feels more stable and easier to use, and as a result, users find that operations run smoothly, compared to some previous versions. Still, some users have problems installing certain apps and software. Such is the case of Docker Compose.

In the following tutorial, we will show you how to install Docker Compose on Ubuntu 20.04 server.


  • A new Ubuntu 20.04 VPS.
  • Access to the root user account

  • (or access to an administrator account with root privileges)

Step 1: Log in to the server and

update the server OS packages

First, log in to your Ubuntu 20.04 server via SSH as root user:

ssh [email protected]_Address -p Port_number

You will need to replace ‘IP_Address‘ and ‘Port_number ‘ with the respective IP address of your server and the SSH port number. Also, replace ‘root‘ with the username of the administrator account if necessary.

Before you begin, you need to make sure that all Ubuntu 20.04 OS packages installed on the server are up to date. You can do this by running the following commands

: apt-get update -y

Step 2: Install docker-compose

on the server

By default, Docker Compose is available in the default Ubuntu 20.04 repository. You can install it

with the following command: apt-get install docker-compose

Once Docker Compose

is installed, verify the installed version with the following command: docker-compose -version

You should get the following output:

docker-compose version 1.25.0, build unknown

This option will not guarantee that you download the latest version of docker-compose.

In the GitHub repository, you will get Docker Compose updates, which might not be available in the standard Ubuntu repository. At the time of writing this tutorial, the most current stable version is 1.29.2.

curl -L “$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose This command saves the file to: /usr/local/bin, under the name docker-compose.

Next, you need to change the file’s permission and make the downloaded file executable

with the following command: chmod +x /usr/local/bin/docker-compose


Docker Compose is installed, verify the installed version with the following command: docker-compose -version

You should get the following output



version 1.29.2, build 5becea4c

Step 3: Test Docker Compose with

A sample container

Create a new directory for the sample container Example


Change directory you just created

: CD Test

From there, create a YAML

configuration file: nano docker-compose.yaml And copy the following configuration to the docker-compose.yaml file: Version: ‘3.3’ Services: Hello-World: Image: Hello-World:latest

Then run the following command to extract the

hello-world image to your system

. docker-compose


The output should look something like this

: Creating network “root_default” with the default driver Pulling hello-world (hello-world:latest)… Latest: Extracting from library/hello-world 2db29710123e: Pull complete Digest: sha256:9ade9cc2e26189a19c2e8854b9c8f1e14829b51c55a630ee675a5a9540ef6ccf Status: Downloaded Newest image for hello-world:latest Creating root_hello-world_1 … Done Attach to root_hello-world_1 hello-world_1 | Hello-world_1 | Hello from Docker! Hello-world_1 | This message shows that the installation appears to be working correctly. Hello-world_1 | Hello-world_1 | To generate this message, Docker performed the following steps: hello-world_1 | 1. The Docker client contacted the Docker daemon. Hello-world_1 | 2. The Docker daemon extracted the “hello-world” image from the Docker Hub. Hello-world_1 | (amd64) Hello world_1 | 3. The Docker daemon created a new container from that image that runs the hello-world_1 | executable that produces the output you are currently reading. Hello-world_1 | 4. The Docker daemon transmitted that output to the Docker client, which sent it hello world_1 | to your terminal. Hello-world_1 | Hello-world_1 | To try something more ambitious, you can run an Ubuntu container with: hello-world_1 | $ docker run -it ubuntu bash hello-world_1 | Hello-world_1 | Share images, automate workflows, and more with a free Docker ID: hello-world_1 | Hello-world_1 | Hello-world_1 | For more examples and ideas, visit: hello-world_1 | Hello-world_1 | root_hello-world_1 came out with the code 0

After downloading the image, Docker Compose creates a container and runs the

hello-world program.

If you want to view the container information, you can use the following command

: docker ps -a

The output should look something like

this: CREATED CONTAINER ID IMAGE COMMAND STATE PORT NAMES 31b0b7a2e9f0 hello-world:latest “/hello” 17 minutes ago Sold out (0) 17 minutes ago root_hello-world_1

In this tutorial, we learned how to install Docker Compose on your Ubuntu 20.04 server, as well as the basics of how to use it.

Of course, you don’t need to do any of this if your server is covered by our managed Linux support services, in which case you can simply ask our expert Linux administrators to install Docker Composer on your Ubuntu 20.04 server for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, please share it with your friends on social media using the buttons below, or just leave a comment in the comments section. Thank you.

Contact US