Install Docker Compose Linux

  1. Install Docker Compose Amazon Linux 2
  2. Install Docker Compose Linux Mint 20
  3. Install Docker-compose Amazon Linux
  4. Install Docker Compose Linux Mint 19
  5. Install Docker-compose-linux-x86_64

Docker Compose is a Python program that lets you easily deploy multiple containers on a server.

The CLI is a drop-in replacement for the previous Python program docker-compose. The Python version is much slower than the new Go version. If you want to use compose v2 on your Linux machine, you have to install it manually. Install Compose V2 on Linux. Find the latest release with the v2 tag. Currently, that’s v2.0.0-beta.3. A separate 'compatibility package' could be possible, but if docker-compose v1 is not deprecated, it should not come by default. For Docker Desktop, the installation is somewhat more 'opinionated', but for a Linux server install, things are more involved.

  1. $ sudo apt install docker-compose This will install the 1.25.0 version of docker compose which is a bit older. At the time of writing this answer the current version is 1.29.1. Another alternative is to use Docker Compose as Docker Container. Use the following commands to run Docker Compose Container.
  2. Sep 02, 2020 $ sudo apt install docker-compose This will install the 1.25.0 version of docker compose which is a bit older. At the time of writing this answer the current version is 1.29.1. Another alternative is to use Docker Compose as Docker Container. Use the following commands to run Docker Compose Container.
  3. How to Install Docker Compose on your Linux Instance September 06 2021 Docker Compose is a tool, that is used to run multi-container Docker applications, with Compose you use a YAML file to configure applications run each container will run a standalone services.

As you start exploring Docker, you'll learn that often to run a certain web-app, you'll need to run various services (like database, web-server etc) in different containers.

Deploying multiple containers is a lot easier if you use Docker Compose.

In this tutorial, you'll learn two ways of installing Docker Compose on Ubuntu:

  • Installing Docker Compose from Ubuntu's repository: Easier method but may not have the latest version of docker compose
  • Installing the latest Docker Compose using PIP: Gets you the newer docker compose version

Keep in mind that to use Docker Compose, you must have Docker installed on Ubuntu.

Install Docker Compose from Ubuntu's repository

This is the easiest and recommend method. Unless you need the latest Docker Compose version for some specific reasons, you can manage very well with the docker compose version provides by Ubuntu.

Docker Compose is available in the universe repository of Ubuntu 20.04 and 18.04 so make sure to enable it first:

You probably won't need it but no harm in updating the local cache:

Now you can install Docker Compose in Ubuntu using this command:

You can check that Docker Compose is installed successfully by checking its version:

It should show an output like this:

Install the latest Docker Compose on Ubuntu using PIP

PIP stands for 'PIP Installs Package'. It's a command-line based package manager for installing Python applications.

Since Docker Compose is basically a Python program, you can use PIP to install it.

But before you do that, you need to install PIP on Ubuntu first.

Enable the universe repository first.

Install PIP now:

Now that you have PIP installed use it to install Docker Compose for all users on your Linux system:

Check the Docker Compose version to ensure that it is installed successfully:

You can see that Docker Compose installed via PIP is more recent version.

I hope you were able to successfully install Docker Compose on Ubuntu with this tutorial. I highly recommend reading this quick starter guide to Docker Compose.

Install Docker Compose Amazon Linux 2

Questions and suggestions are welcome.

Docker Compose is a tool that natively integrates with Docker, and makes managing multi-container applications a breeze.

The benefits Docker Compose provides are numerous, some of which include:

  1. Manage Container Networks Easily: Connecting two containers via a Docker network is super simple in Docker Compose, being as simple as defining a network and telling the containers to connect to it. In addition, Docker Compose can automatically create and destroy networks as you create and destroy the containers themselves.
  2. Container Dependencies: You have a Docker container that needs another Docker container to be up and running, say, a database. Docker Compose allows you to define dependencies for a container, requiring the dependencies to be up and running before anything else will start.
  3. Reproducible Setups: Since the container setup will be defined before anything is even created, this allows for reproducibility of setups, making it easier to transfer them to other systems. While you could theoretically do such in something like Bash, it can make things less flexible and harder to adapt to change.

Installing Docker Compose on Linux

Docker Compose is readily available in most distributions repositories.

Install Docker Compose Linux Mint 20

You can install Docker Compose on Ubuntu and Debian-based distributions using the following command:

On Arch and Manjaro, you may use:

On Fedora, you can use the dnf command:

You may need to put a bit more effort in installing Docker Compose on CentOS.


For any other distributions, you can always look at the installation docs for information on obtaining the needed packages.

Creating Our First Docker Compose File

This guide assumes you're already familiar and comfortable with the docker CLI tool. If you're not, consider getting so, as you'll likely run into a bunch of simple hiccups otherwise.

Docker Compose files are stored under the name docker-compose.yml, and are automatically found when you run docker-compose commands in the same directory. Its syntax takes the form of, you guessed it, YAML.

We have a dedicated tutorial on YAML basics if you are interested in learning about it.

We're going to start with a file that creates a Nextcloud instance, then go over how it actually did what it did.

First things first, you need to create the compose file. Create an empty directory on your system, and create the docker-compose.yml file.

Next, fill the file with the following content:

Now all you have to run is docker-compose up -d, and you would have successfully deployed Nextcloud with Docker.

Here's the login page of Nextcloud.

Understanding our Docker Compose File

Now that you have seen that the file actually works, let's go over the contents of the file so that you can actually understand what exactly it's doing.

The 'version' Tag

First things first, the version tag. This is just specifying the version of the Docker Compose file format, as different versions will have different syntax. You generally want to keep this to the latest version, but it doesn't have to, which can be helpful if you have some legacy files.

The 'services' Tag

Next, you see the services tag. This starts the list for all the applications that are created when docker-compose up -d is ran.

Followed by this we start the listing for our first container, nextcloud_app. This serves as the identifier for the app, which can be used by other Docker Compose commands. Note that this is not the name of the container itself - that's specified in the next part.

Now, you start defining everything about your container. Here is a brush-up on what all the fields mean, though most should be self-explanatory if you already know your way around Docker:

  • container_name - Defines the name of the container. Equivalent to the --name option.
  • image - Defines what image to pull from for the container.
  • restart - Defines the restart policy for the container. Equivalent to --restart.
  • networks - Defines a network that the container connects to. This network can be created or can already exist. This value serves as an identifier for docker-compose and is not the actual name of the network (that's defined in the networks tag section).
  • ports - Defines host ports that the container can connect to. Equivalent to --publish.
  • volumes - Defines volumes for the container. Equivalent to --volume.
  • environment - Defines environment variables for the container. Equivalent to --env. This option supports two syntax types. The first is variable: value, which is what is used here. The other option, which may be more familiar if you are used to the docker CLI syntax, is - variable=value.
  • depends_on - Specifies container dependencies. This is used to require a container to not start until its dependencies have. This accepts values from the container listings. (Not container_name!)

The 'networks' Tag

Install Docker-compose Amazon Linux

Now you get to the networks tag. This is used to define the networks we listed under networks for our containers.

Inside the networks section, you first list the identifier that you gave to the network under services. Here, that was nextcloud.

Next, you define the name of the network that can be seen with docker network ls. Here, we named it nextcloud_docker_network.

Install Docker Compose Linux Mint 19

If you wanted the containers to join a network that already existed, you would use the following syntax, replacing network_name with the name of the Docker network:

And there you go. That sums up the whole file!

You may name the yml file anything but then you'll have to specify the filename when using the docker-compose commands. Keeping up the tradition and naming it docker-compose.yml keeps the commands short.

Closing Up

Now you know the basics to using Docker Compose, and the benefits you can get through its use. You're also now on your way to understanding what people are doing when they distribute their containers through Compose files.

Install Docker-compose-linux-x86_64

Something not working, or got some lingering questions? You are welcome to leave them in the comment section below.