Comprehensive Steps To Install Docker Compose on Centos 7
This article provides a comprehensive, step-by-step guide on how to Install Docker Compose on Centos 7. Docker Compose is a powerful tool that simplifies the process of defining and managing multi-container Docker applications using a YML file. By following the instructions below, hosted on the Orcacore website, you can easily set up Docker Compose with the latest version downloaded directly from GitHub.
To successfully complete this guide on utilizing Docker Compose commands, you’ll need access to your Centos 7 server with either root privileges or a non-root user account with sudo privileges. If you require assistance with the initial server setup, you can refer to this guide on Initial Server Setup with Centos 7.
Furthermore, ensure that Docker is already installed on your server. If not, please consult this guide on How to Install and Use Docker on Centos 7 before proceeding.
Once Docker is installed, you can proceed with the following steps to complete your Install Docker Compose on Centos 7.
Step 1 – Verify Docker Installation on Centos 7
Before proceeding with the Install Docker Compose on Centos 7 procedure, confirm that Docker is properly installed by checking its version.
docker --version

Step 2 – Download Docker Compose Binary Package
Now, visit the GitHub Docker Compose release page and use the curl command to download the latest binary package to the /usr/local/bin/
directory:
sudo curl -L "https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Next, set the correct permissions for the Docker Compose binary on Centos 7 using the following command:
sudo chmod +x /usr/local/bin/docker-compose
Step 3 – Verify Docker Compose Installation on Centos 7
Verify the Install Docker Compose on Centos 7 by checking its version:
sudo docker compose version
**Output**
Docker Compose version v2.18.1
Step 4 – How To Use Docker Compose?
To ensure that Docker Compose commands are functioning correctly, let’s test it with a sample Docker container on Centos 7.
First, create a new directory for setting up the docker-compose
file with the command below:
mkdir compose-test
Navigate to your directory with the command below:
cd compose-test
Then, create a docker-compose.yml
file. This is a configuration file where you can define your container’s information.
To create the file, use the following command or your preferred text editor. Here, we use the vi editor:
sudo vi docker-compose.yml
Add the following basic hello-world container based on the latest hello-world image:
version: '2'
services:
hello-world:
image:
hello-world:latest
Save and close the file.
Docker Compose Up Command
Launch the container within the compose-test
directory:
sudo docker compose up
**Output**
[+] Running 2/2
⠋ hello-world 1 layers [⠋] 0B/0B Pulled 2.6s
⠋ 719385e32844 Pull complete 0.5s
[+] Building 0.0s (0/0)
[+] Running 2/2
⠋ Network compose-test_default Created 0.1s
⠋ Container compose-test-hello-world-1 Created 0.1s
Attaching to compose-test-hello-world-1
compose-test-hello-world-1 |
compose-test-hello-world-1 | Hello from Docker!
compose-test-hello-world-1 | **This message shows that your installation appears to be working correctly.**
...
The output confirms that your Docker Compose is working correctly on Centos 7.
Step 5 – Uninstall or Remove Docker Compose
To uninstall Docker Compose from your system, first, remove the docker-compose binary package by using the following command:
sudo rm /usr/local/bin/docker-compose
Uninstall the Docker Compose software by running this command:
sudo yum remove docker-compose
Finally, uninstall all unwanted software dependencies by typing the following command:
sudo yum autoremove
Conclusion
You have now successfully learned how to Install Docker Compose on Centos 7 with the latest version and use Docker Compose commands. You also tested your installation by creating a sample hello-world YML file. Using Docker Compose simplifies the creation and sharing of multi-container applications in a YML file.
Hope you enjoyed it. You may also be interested in these articles:
Install ionCube PHP Loader on Rocky Linux 9
How To Set up Grafana on Rocky Linux 9
How To Install OpenJDK 17 on Debian 11
Alternative Solutions for Installing Docker Compose on Centos 7
While the previous method focused on downloading the binary directly from GitHub, alternative solutions exist for installing Docker Compose on Centos 7, offering different levels of convenience and management.
Alternative 1: Using the Docker Repository (If Available)
Sometimes, the Docker repository itself might contain a Docker Compose package. While not always the most up-to-date, this method can be simpler for some users.
Explanation:
This approach relies on the official or a trusted third-party Docker repository containing a pre-packaged Docker Compose version. This simplifies the installation process by leveraging the system’s package manager (yum in this case) to handle dependencies and updates. However, the version available might not be the latest.
Steps:
-
Ensure the Docker Repository is Enabled: If you installed Docker using a repository, it should already be enabled. Double-check using
yum repolist
to confirm that the Docker repository is listed. If not, you’ll need to add it (refer to the official Docker documentation for Centos 7). -
Install Docker Compose using yum:
sudo yum install docker-compose
-
Verify Installation: After installation, verify the version using:
docker-compose --version
Caveats:
- The
docker-compose
command might be located in/usr/bin
or/usr/local/bin
, depending on the repository configuration. - The installed version might not be the absolute latest. Check the repository’s package information for the version number.
Alternative 2: Using pip (Python Package Installer)
Another common method to Install Docker Compose on Centos 7 is by using pip
, the Python package installer. This method is particularly useful if you prefer a Python-based installation or if the binary method presents issues.
Explanation:
Docker Compose is fundamentally a Python application. Installing it via pip
leverages Python’s package management system. This can be advantageous if you already have a Python environment set up and prefer managing Docker Compose as a Python package.
Steps:
-
Install pip: If you don’t have pip installed, install it first:
sudo yum install python-pip
On older systems, you might need
python3-pip
instead. -
Install Docker Compose using pip:
sudo pip install docker-compose
It’s generally recommended to use
sudo
withpip
to install Docker Compose system-wide. Consider using a virtual environment for more isolated installations. -
Verify Installation:
docker-compose --version
If you encounter the error
docker-compose: command not found
, it means that the directory wherepip
installed Docker Compose is not in yourPATH
. You can find the location by runningpip show docker-compose | grep Location
. Then, add that directory to yourPATH
environment variable. A temporary solution is to use the full path when executing Docker Compose (e.g.,/usr/local/bin/docker-compose
).
Caveats:
- Requires Python and pip to be installed.
- May require adjusting the
PATH
environment variable. - Conflicts can arise if different Python versions or environments are used. Using virtual environments is recommended for managing dependencies in such cases.
- The command to run docker-compose is
docker-compose
, notdocker compose
like in the first method.
These alternative methods offer flexibility in how you choose to Install Docker Compose on Centos 7, catering to different preferences and system configurations. Remember to choose the method that best suits your needs and ensure that you verify the installation afterward.