Bobcares

How To Install Docker Compose on Ubuntu 18.04?

by | Sep 8, 2020

Are you facing errors while trying to install docker-compose on a Ubuntu server?

sometimes errors can occur due to a lack of packages or application dependency issues.

As a part of our Server Management Services, we help our customers to install Docker compose on different servers and to fix installation errors.

Today, let’s see related common errors and fixes for them.

How To Install Docker Compose on Ubuntu 18.04?

Docker is a tool for automating the deployment of Linux applications within the containers.  However,  each component of an application should run in its own container.

To overcome this, a tool called Docker Compose is used for defining and running multi-container Docker applications. Therefore, it lets users launch, execute, communicate, and close containers with a single coordinated command.

Here, let’s discuss how Support Engineers install docker-compose on Ubuntu. Before proceeding to install docker-compose, it mandatory to install docker on the sever.

1. Initially, we update Software Repositories and Packages using the below commands.

apt-get update

apt-get upgrade

2. Then, we download the latest Docker Compose Version. For that, we use the below command.

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

The description of the above command is,

  • -L: tells the system to follow any redirects, in case the file has been moved.
  • If a different version of Docker Compose needed to install, then substitute the preferred version for /1.24.0/.
  •  –o: tells to changes the filename.
  • The saved location of the file in /usr/local/bin/.

3. Next, we change the file permissions to allow the new software to be executed on Ubuntu:

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

To verify the status of installation we check the docker version

docker-compose --version

 

How to run a Container with Docker Compose

The public Docker registry, Docker Hub, provides a Hello World image for testing purposes. It demonstrates the minimal configurations required to run a container using Docker Compose.

1. First, we create a directory for the YAML file and move into it:

mkdir hello-world
cd hello-world

2. Then, we create the YAML file,docker-compose.yml :

nano docker-compose.yml

3. After that, we put the following contents into the file and save the file.

~~
my-test:
image: hello-world

~~

The explanation of the YML file entries are given below,

  1. The first line is used as part of the container name.
  2. The second entry describes which image to use to create the container.

 

4. Then, we execute the following command from the ~/hello-world directory.

docker-compose up

When we run the command docker-compose up it will take the local image by the name we specified, hello-world. Moreover, to ensure if the local images present in the server, we use the docker images command:

docker images

The first time we run the command, Docker Compose will pull it from the Docker Hub public repository if there is no local image called hello-world on the server.

 

Common error while installing docker-compose in Ubuntu

Let’s see how our Support Engineers fix the Docker compose installation errors.

 

1. Missing curl and pip package

Often, customers get an error while installing docker-compose on Ubuntu.For instance, customers get the below error after running installation commands:

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

The substitute to apt-get is the Python Package Installer or pip. So, initially, pip needs to be installed.

apt-get install python-pip

Then, we install docker-compose with pip

pip install docker-compose

This fixes the error.

 

Sometimes, customers get an error while installing docker compose due to missing cul package.

To install cURL for Ubuntu Linux.

1. We update the Ubuntu, run apt update && apt upgrade

2. Next, we install cURL by running apt install curl.

This resolves the error.

 

[Need assistance to fix Docker compose installation errors? – Our Support Engineers will help you.]

 

Conclusion

n short,  Docker Compose requires some packages like pip and curl to be installed on Ubuntu. Today, we saw how our Support Engineers install docker-compose on Ubuntu.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.