Installing Docker Compose on CentOS

Reading Time: 2 minutes

Installing Docker Compose on CentOS is an article that shows all the necessary steps to install the Docker Compose on CentOS.

In this example, we are using the CentOS 7!

First and Foremost, what is the Docker Compose?

Docker Compose is a tool for defining and running multi-container Docker applications. With this tool, we can use a YAML file to configure our application services. Then, with a single command, we can create and start all the services (containers) from our configuration.

YAML is a language used to represent data. It is a very popular language used in a lot of places, like system configurations, codes, and so on.

You can check more details of Docker Compose in the following link:
https://docs.docker.com/compose/

In simple words (using my simple words), with the Docker Compose we can start our containers simply and logically. If you have a 3-Tier application, for instance, you can specify in a doc ker-compose.yml file all the necessary steps to start each application.

Just to share with you, here we can see an example of a docker-compose.yml file that I am working on at the moment.

Here, we can see all services (db, app, and web) that will be started by the Docker Compose tool. Look that this file has been written using the YAML language:

root@debian11:~/3-tier_compose# cat docker-compose.yml
services:
 db:
  image: db-image
  ports:
  - 3306:3306
  environment:
    MYSQL_ROOT_PASSWORD: Hjajxkkkakk87juaJlllaaxa3
  volumes:
  - /docker/volumes/db:/var/lib/mysql
 app:
  image: app-image
  ports:
  - 5001:80
 web:
  image: web-image
  ports:
  - 8080:80

Let’s Get Started: Install the Docker Engine

Firstly, we need to install the Docker Engine on CentOS. We have written an article explaining all the necessary steps for that. You can access this post at the following link:
https://www.dpcvirtualtips.com/installing-docker-engine-on-centos/

Install Docker Compose

By default, the Docker Compose is not available in the CentOS 7 default repository. So, we need to download it binary from GitHub:

curl -L https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

Adjust the file permission just to add the execute permission:

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

And that’s it 🙂
We can execute the docker-compose to check the version installed:

docker-compose --version

Now, the Docker Compose is installed and ready to be used! 🙂