Docker Compose, different installation options in Ubuntu 20.04

about docker compose

In the next article we are going to take a look at Docker Compose. This is a utility that helps define, view, and run multiple applications. Is about a tool to build isolated containers through YAML files.

Docker Compose allows you to run multiple copies of the environment on a single host. Instead of using Docker using a series of bash commands and scripts, Docker Compose allows you to use YAML files to be able to instruct the Docker Engine to perform tasks. And this is the key, the ease of giving a series of instructions, and then repeating them in different environments.

Docker Compose is a tool for run multi-container applications in Docker defined using the Compose file format. A composition file is used to define how one or more containers that make up our application are configured. Once we have the composition file, we can create and start our application with a single command: docker-compose up.

Docker Compose is a tool that simplifies the use of Docker. From YAML files, it is easier to create containers, connect them, enable ports, volumes, etc. With Compose you can create different containers and at the same time, in each container, different services, join them to a common volume, start them, turn them off, etc. It is a fundamental component to be able to build applications and microservices. All Compose features can be viewed in detail from the page of project documentation.

Install Docker Compose on Ubuntu 20.04

Users can choose to different options to install this utility, as they are:

From the Ubuntu repository

From Ubuntu repositories we can get a stable version and updates of this tool. To install from here, we just need to open a terminal (Ctrl + Alt + T) and type the following command to install the utility from the official repository:

install docker compose with apt

sudo apt install docker-compose

Once the installation is complete, we can check if it has been installed correctly in our system. We can do this by writing the following command in the same terminal:

docker compose apt version

docker-compose version

Uninstall

For remove Docker Compose installed with apt, we just need to open a terminal (Ctrl + Alt + T) and execute the command:

Uninstall with apt

sudo apt remove docker-compose; sudo apt autoremove

Using the GitHub repository

At repository on GitHub from this project, we can get a more updated version of Docker Compose, which may not be available in the standard Ubuntu repository.

If you want install an updated version of the Docker Compose utility, you can use web browser or open a terminal (Ctrl + Alt + T) and run the following command to get the latest version published today:

download docker compose from github

sudo wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.28.6/docker-compose-Linux-x86_64

Once the download is finished, we will use this other command to assign the necessary permissions to the executable file that we have downloaded in the previous step:

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

Now we can check the version that we are going to have available using the following command in the terminal:

docker compose version from GitHub

docker-compose --version

Uninstall

This tool can be removed from the system just by deleting its binary file. Therefore, we will need to open a terminal (Ctrl + Alt + T) and use the following command to uninstall it from our computer:

sudo rm /usr/local/bin/docker-compose

Using pip

We can also download Docker Compose using pip3. This utility requires Python 3.6 or later and its pip package manager, to work correctly. If you have this version of these requirements, in a terminal (Ctrl + Alt + T) you just need to use the following command to install:

install pip3 docker compose

pip3 install docker-compose

Uninstall

For eremove this utility, if you have installed it with pip3, we will only need to open a terminal (Ctrl + Alt + T) and execute the command in it:

uninstall using pip3

pip3 uninstall docker-compose

If you want try a Docker Compose usage example, on the documentation page of this project, they offer a very complete example. With it you can check the operation of this software.

Compose works in all environments: production, staging, development, testing, and CI workflows. It can be obtained more information about each case in common use cases.

Add Comment