Managing multiple docker containers on CLI could be a painful task, docker-compose is an easy to use solution to manage all your docker containers inside a docker-compose.yml file. You can run multiple docker containers inside one compose file. In this Guide I will show you how to install docker-compose on your Debian or Ubuntu server.

Install docker-compose on Linux

Make sure you have curl installed on your system. For Debian or Ubuntu you can do so, by running: apt install curl.

Now you are ready to download the current version of docker-compose directly from their github repo.

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

To allow docker-compose to run, we need to set the excutable flag to /usr/local/bin/docker-compose.

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

That’s it! You can check if docker-compose is installed correctly by running the following command. You should then get the current version as an output.

$ docker-compose version
docker-compose version 1.28.5, build c4eb3a1f

How to run docker-compose.yml?

To start your docker-compose.yml stack, make sure you are in the same directory as your compose file is. Then simply run:

docker-compose up -d

This command will start your docker-compose stack and move it to background. This means your stack is running as long as you want, even if you are closing your SSH connection. To stop your stack use docker-compose stop.