Installing docker compose on ubuntu 18.04

Need to get docker compose installed on your Ubuntu Ubuntu 18.04 server?

This article will show you exactly how to do it correctly and fix common docker compose error that might occur during installation.

As part of our Linux Support Services here at Ibmi Media, we do regularly help our customers install docker compose and Linux related software.

How to install Docker Compose on Ubuntu 18.04?

Docker helps in the deployment and management of applications in Linux server within containers. In the deployment automation process, each application runs in its own container. To help application run in their own container, a specialized tool known as Docker Compose comes handy as it helps to define and run multiple applications using docker containers. With this, the launching, execution is processed by using a single interactive command.

To install docker-compose on Ubuntu, you have to install docker first and the complete set up instruction is outlined below;

i. To begin, do an update of the System Software Repositories and packages with the commands below;

apt-get update

apt-get upgrade

ii. Next, we download the latest Docker Compose with the command below;

curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Here "-L" stands for redirects capability instructing the system to follow any redirects if it file source is no longer available.
The file to be downloaded will be saved in the /usr/local/bin/ directory.

iii. Now, the file permission should be checked to permit new software to run on the Server. To do this, use the command below;

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

Then verify the docker compose installation and its version with the command;

docker-compose --version

Running a container with Docker Compose

For testing purposes, a "Hello World" image is provided by Docker Hub which is the public Docker Registry. It shows the standard configurations required to run a container when using Docker Compose. Follow the instructions below;

i. To begin, for the YAML file, create a directory and change to it. That is;

mkdir hello-world
cd hello-world

ii. Now, create the YAML file called "docker-compose.yml" with the command below;

nano docker-compose.yml

iii. Next, we place the following attributes into this file and save;

my-test message:
image: hello-world

Here, the first line is included in the container name. While the image used in the container creation is represented in the second line.

iv. From the /hello-world directory , run the following command;

docker-compose up

The docker-compose up command will assume the local image by the name specified in the earlier part of this guide. Then we check if the local images are available in the server with the command below;

docker images

Common errors encountered while installing docker-compose in Ubuntu

Most Linux users encounter issues while trying to set up docker-compose on their server. We will discuss a few briefly.

Curl and pip package missing

When this pip package or curl is missing on the server, you will get an error message such as this;

apt-get -f install docker-compose
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
code : Depends: libnotify4 but it is not going to be installed
Depends: libnss3 but it is not going to be installed
Depends: libxkbfile1 but it is not going to be installed
Depends: libgconf-2-4 but it is not going to be installed
Depends: libsecret-1-0 but it is not going to be installed
docker-compose : Depends: python-cached-property but it is not going to be installed

To install pip, which is a Python Package on Ubuntu, simply use the command below;

apt-get install python-pip

After installation successfully, you can now you can now proceed with docker-compose installation using pip with the command;

pip install docker-compose

This will resolve the error.

In other cases, curl package may be missing and result in the error. When this is the cause, installing curl will fix this error. To get cURL installed on Ubuntu, follow the steps below;

i. To begin, update the Server environment with the following command;

apt update && apt upgrade

ii. Then, install cURL with the command;

apt install curl

This will solve the error.

Need support in fixing Docker Compose errors while Installing docker-compose? Our Support team is available.


Missing cUrl and pip packages on Linux Server can trigger Docker Compose installation failures. This guide will show you how to install docker-compose on Ubuntu without any installation issues.