Install and Configure Docker Compose for Ubuntu. This guide assumes, that Docker is already installed in your system.

Compose is a tool for defining and running multi-container Docker applications. We can use Compose to create and start all services with one command from a single configuration YAML file.

It is a great tool to have a minimal orchestration of Docker containers, without adding the complexity that other tools have, like Kubernetes and Docker Swarm.

Installation

Prerequisites

To install Docker Compose you need to make sure you have Docker Engine installed, follow the previous guide on Installing Docker on Ubuntu, to continue with this guide.

Install Compose

Run this command to download the current stable release of Docker Compose:

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply executable permissions to the binary:

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

Post-installation

Command-line completion

Compose comes with command completion for the bash and zsh shell. We will show how to enable for both bash and zsh.

Bash

Place the completion script in /etc/bash_completion.d/:

sudo curl \
    -L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose \
    -o /etc/bash_completion.d/docker-compose

Reload your settings in your current terminal with:

source ~/.bashrc

Zsh

Make sure you have installed oh-my-zsh on your computer. You can follow the ZSH configuration guide in order to do that.

Add docker and docker-compose to the plugins list in ~/.zshrc to run autocompletion within the oh-my-zsh shell:

plugins=(... docker docker-compose)

Reload your settings in your current terminal with:

source ~/.zshrc

For shell completion without oh-my-zsh, follow the official docker guide.