Install Docker Compose on CentOS Stream 8
This guide will show you how to Install the Latest Docker Compose on CentOS Stream 8.
Docker Compose is a tool designed to define and release multicontainer applications. With Compose, you can create a YAML file to define the services that you can start or stop with a single command.
Definitely, access to the Terminal as a user with sudo privileges.
Step 1: You need curl and wget installed on your system for this operation
### CentOS / RHEL ###
sudo yum -y install curl wget
Step 2: Once curl has been installed, download the latest Compose on your Linux machine
curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | grep docker-compose-linux-x86_64 | cut -d '"' -f 4 | wget -qi -
Step 3: Make the binary file executable
chmod +x docker-compose-linux-x86_64
Step 4: Move the file to your PATH
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
Step 5: Confirm version.
docker-compose version
Docker Compose version v2.2.3
Configure Compose Command-line completion
Compose has command completion for the bash shell.
Step 1: Place the completion script in /etc/bash_completion.d/
sudo curl -L https://raw.githubusercontent.com/docker/compose/master/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
Step 2: Source the file or re-login to enjoy completion feature
source /etc/bash_completion.d/docker-compose
Test Docker Compose installation
Step 1: Create a test Docker Compose file
vim docker-compose.yml
# or
nano docker-compose.yml
Step 2: Add below data to the file
version: '3'
services:
web:
image: nginx:latest
ports:
- "8080:80"
links:
- php
php:
image: php:7-fpm
Step 3: Start service containers
docker-compose up -d
[+] Running 17/17
⠿ php Pulled 13.6s 13.6s
⠿ 5eb5b503b376 Pull complete 2.8s
⠿ 8b1ad84cf101 Pull complete 2.9s
⠿ 38c937dadeb7 Pull complete 6.8s
⠿ 6a2f1dc96e59 Pull complete 6.8s
⠿ bf096f1cde52 Pull complete 8.4s
⠿ bbe92a33044b Pull complete 8.4s
⠿ 12fb9fc9cefa Pull complete 10.9s
⠿ 56f416abdc92 Pull complete 11.0s
⠿ b4e2b115339b Pull complete 11.1s
⠿ c2fb704e3652 Pull complete 11.1s
⠿ web Pulled 11.0s
⠿ 1ae07ab881bd Pull complete 6.7s
⠿ 78091884b7be Pull complete 6.8s
⠿ 091c283c6a66 Pull complete 6.9s
⠿ 55de5851019b Pull complete 8.4s
⠿ b559bad762be Pull complete 8.4s
[+] Running 3/3
⠿ Network bitwarden_default Created 0.2s
⠿ Container bitwarden-php-1 Started 6.9s
⠿ Container bitwarden-web-1 Started 1.3s
Step 4: Show running Containers
docker-compose ps
NAME COMMAND SERVICE STATUS PORTS
bitwarden-php-1 "docker-php-entrypoi…" php running 9000/tcp
bitwarden-web-1 "/docker-entrypoint.…" web running 0.0.0.0:8080->80/tcp, :::8080->80/tcp
Step 5: Destroy containers
docker-compose stop
[+] Running 2/2
⠿ Container bitwarden-web-1 Stopped 0.2s
⠿ Container bitwarden-php-1 Stopped 0.1s
docker-compose rm -f
Going to remove bitwarden-web-1, bitwarden-php-1
[+] Running 2/0
⠿ Container bitwarden-web-1 Removed 0.0s
⠿ Container bitwarden-php-1 Removed 0.0s
Go through Official Docker documentation and Docker Compose documentation to learn more. Source of this Tutorial: https://computingforgeeks.com/how-to-install-latest-docker-compose-on-linux/ and self-tested by me.
If you have any questions please leave it in the comments and if you need Docker management UI which allows you to easily manage your different Docker hosts and containers, please give Portainer a try. It is easy to install and use. You can find the Tutorial here: . 🙂