15 C
Texas

How To Install Latest Docker Compose on Ubuntu 19.04 / CentOS 8 / Debian 10 / Fedora 30

In our previous tutorial we’ve seen How To Install Docker on Ubuntu 16.04 18.04 / 19.04. Now we’ll move further to Install Docker Compose on different Linux distributions like Ubuntu, Debian, CentOS and Debian.

What is Docker Compose?

Docker Compose is a tool that provides us the facility to define and run multi-container Docker application. A YAML file is the configuration file used to configure your application’s services.
So, we are going to Install Docker Compose in as much details as possible so you can easily understand and Install it. For this Installation we’ll check Github API releases page for our project. After it we’ll pull out the latest binary file for our Installation process. So, follow the below steps to move further.

Step 1: Installing Latest Docker Compose on Linux

Requirements:

You must have installed Curl on your system for this operation.
Access to the root or user with root privileges.

- Advertisement -
---- CentOS / RHEL -----
$ sudo yum -y install curl
---- Debian / Ubuntu ----
$ sudo apt install -y curl
----- Fedora -----
$ sudo dnf -y install curl

After Installing curl move to the next point which is Downloading 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 -

Make sure to make binary file executable.

chmod +x docker-compose-Linux-x86_64

Now, move the file to your PATH.

sudo mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

Check the version you’ve installed.

docker-compose version

Step 2: Configure Compose Command-line completion.

Compose has command completion for the bash & zsh shell.

Bash users.

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

Source the file or re-login to enjoy completion features.

source /etc/bash_completion.d/docker-compose
Zsh users

Download the completion script in your ~/.zsh/completion/

mkdir -p ~/.zsh/completion
curl -L https://raw.githubusercontent.com/docker/compose/master/contrib/completion/zsh/_docker-compose > ~/.zsh/completion/_docker-compose

Include the directory in your $fpath by adding in ~/.zshrc

fpath=(~/.zsh/completion $fpath)

Double check that compinit is loaded or load it by adding in ~/.zshrc.

autoload -Uz compinit && compinit -i

After-it reload your shell.

exec $SHELL -l

Step 3: Test Docker Compose Installation

Make a file for testing docker compose.

vim docker-compose.yml

Copy & paste the below data in the file.

version: '3'  
services:
web:
image: nginx:latest
ports:
- "8080:80"
links:
- php
php:
image: php:7-fpm

Start the containers services.

$ docker-compose up -d
Starting root_php_1 … done
Starting root_web_1 … done

Output:

Show running Containers

$ docker-compose ps
Name Command State Ports
root_php_1 docker-php-entrypoint php-fpm Up 9000/tcp
root_web_1 nginx -g daemon off; Up 0.0.0.0:8080->80/tcp

Destroy Containers.

 $ docker-compose stop
Stopping root_web_1 … done
Stopping root_php_1 … done

$ docker-compose rm -f
Going to remove root_web_1, root_php_1
Removing root_web_1 … done
Removing root_php_1 … done

For detailed description or learning more about Docker documentation & Docker Compose documentation visit their official page .

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article