docker-compose

Install Docker Compose on Ubuntu 18.04

Introduction

Docker Compose is a useful tool that is used to define applications that run more than one container.

An example of this might be a WordPress installation. You might want an Apache Webserver running PHP for the actual WordPress Installation and a separate container running MySQL for the database. Now you have 1 application that needs 2 containers and Docker Compose can really help you manage this.

Installation

To follow along with this tutorial you need an Ubuntu 18.04 machine with Docker installed.

You can find out how to do this on my other tutorial Install Docker on Ubuntu 18.04

The easiest way to get started it to directly download the binary from the Official Docker Website.

# Download docker-compose and place it in /usr/local/bin.
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

At the time of writing the latest stable version of Docker Compose is 1.25.4. To change the version all you need to do it modify the command and change the version in the URL.

The previous command downloads the Docker Compose Binary and places it in /usr/local/bin. This places the file within a directory that is listed in Ubuntu’s default PATH meaning that we can run it from the command line. Before we can do that though, we need to make the file executable.

# Make Docker Compose Executable.
sudo chmod +x /usr/local/bin/docker-compose

That’s it! You now have Docker Compose installed on your server and all we have left to do it test that everything is working.

# Test Docker Compose Installation.
sudo docker-compose --version

Summary

Docker Compose is an excellent tool used to configure and deploy stacks of containers. It is not only used for standalone configuration like the one we have installed but also Docker Swarms that I might get into a little later.

Leave a Reply

Your email address will not be published. Required fields are marked *

Close