How to install Docker Compose on CentOS Stream 9
This guide shows you how to install Docker Compose version 2.24.0 on CentOS Stream 9 using the official binary. Follow these steps to get Docker Compose running on your VPS.
You will install Docker Compose version 2.24.0 on a fresh CentOS Stream 9 system. These steps target CentOS Stream 9 with the standard kernel and require root privileges to execute.
Prerequisites
- Operating System: CentOS Stream 9 (latest update)
- Required Packages: curl, unzip (install via
dnf install -y curl unzipif missing) - Privileges: Root access or sudo privileges
- Network: Internet connectivity to download the binary
Step 1: Create a dedicated directory for Docker Compose
Create a directory in the /opt folder to store the Docker Compose binary. This keeps system files separate from application binaries.
mkdir -p /opt/docker-compose
Verify the directory was created successfully.
ls -ld /opt/docker-compose
You will see output similar to this:
drwxr-xr-x. 2 root root 4096 Jan 15 10:00 /opt/docker-compose
Step 2: Download the official Docker Compose binary
Use the curl command to download the Docker Compose binary directly from the GitHub releases page. Specify version 2.24.0 to ensure compatibility with the latest Docker Engine.
curl -LO https://github.com/docker/compose/releases/download/v2.24.0/docker-compose-linux-x86_64
The download progress bar will appear. Once complete, the file will be saved in your current directory.
Step 3: Verify the downloaded file integrity
Check the SHA256 checksum of the downloaded file to ensure it has not been tampered with. The official checksum for version 2.24.0 is provided by the Docker team.
sha256sum docker-compose-linux-x86_64
Compare the output with the expected hash. The output should look like this:
8f2b9c5d1a3e4f6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b docker-compose-linux-x86_64
If the hashes match, the file is valid. If they differ, delete the file and re-download it.
Step 4: Move the binary to the dedicated directory
Move the downloaded binary into the /opt/docker-compose directory you created in Step 1.
mv docker-compose-linux-x86_64 /opt/docker-compose/docker-compose
This renames the file to docker-compose and places it in the correct location.
Step 5: Set executable permissions on the binary
Make the binary executable so you can run it from any directory. Use chmod to add execute permissions for the owner, group, and others.
chmod +x /opt/docker-compose/docker-compose
Verify the permissions were set correctly.
ls -l /opt/docker-compose/docker-compose
You will see output like this:
-rwxr-xr-x. 1 root root 78M Jan 15 10:05 /opt/docker-compose/docker-compose
Step 6: Create a symbolic link for easy access
Create a symbolic link in the /usr/local/bin directory. This allows you to run docker compose from anywhere without typing the full path.
ln -s /opt/docker-compose/docker-compose /usr/local/bin/docker-compose
This creates a link named docker-compose that points to the actual binary.
Verify the installation
Run the docker compose version command to confirm Docker Compose is installed and accessible from the command line. This command uses the new plugin syntax introduced in version 2.0.
docker compose version
You should see output similar to this:
Docker Compose version v2.24.0
If you see an error saying the command is not found, check that the symbolic link was created correctly in Step 6.
Troubleshooting
If you encounter issues, follow these steps to resolve common problems.
Problem: Command not found
If running docker compose version returns command not found, the symbolic link was not created or the /usr/local/bin directory is not in your PATH.
ls -l /usr/local/bin/docker-compose
If the link is missing, recreate it:
ln -s /opt/docker-compose/docker-compose /usr/local/bin/docker-compose
Reload your shell environment if necessary:
source ~/.bashrc
Problem: Permission denied
If you get a permission denied error when running the binary, ensure the file is executable and owned by root.
chown root:root /opt/docker-compose/docker-compose
chmod 755 /opt/docker-compose/docker-compose
Problem: Docker Engine not installed
Docker Compose requires the Docker Engine to be installed. If you see errors about the Docker socket, install Docker Engine first:
dnf install -y docker
systemctl start docker
systemctl enable docker
Ensure the Docker service is running before using Docker Compose.