How to install Docker Compose

Docker Compose is a powerful tool for defining and running multi-container applications. Instead of running individual commands for each container, you can define the entire environment in a single docker-compose.yml file and launch the entire application stack with one command docker-compose up.

Install compose on Linux

There are multiple ways to install Docker Compose on Linux. In this guide, we will cover two of the most common methods: using cURL and pip. The best method for you depends on your specific requirements.

If you haven’t already set up cURL, learn how to download a file with cURL command. Similarly, if you need to install pip if not already installed, see our step-by-step guide on setting up pip for Linux.

For both methods, ensure that you have command line access and are connected to your VPS via SSH.

Install with cURL

1. First, download the Docker Compose binary using cURL. Run the following command in your command line interface:

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

2. After the download completes, grant executable permissions to the binary with the following command:

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

3. Finally, verify that compose is installed correctly by running the command:

docker-compose --version

Install using pip

1. If you haven’t already installed pip, start by running:

apt-get install python3-pip

2. Then, install Docker Compose with pip:

pip3 install docker-compose

3. Once installed, verify that compose is working by running the following command.

docker-compose --version

Installation on Windows

1. Download and install Docker Desktop for Windows from Docker’s website.

    2. After installation, open a command prompt or PowerShell and check the version by running

    docker-compose --version

    Installation on macOS

    1. Download and install Docker Desktop for macOS from Docker’s website.

    2. Open Terminal and verify the installation by running:

    docker-compose --version