Installing Docker Compose

Installing Docker Compose

ยท

4 min read

Here are two common scenarios for installing Docker Compose:

  1. Scenario one: Install Docker Desktop

The easiest and recommended way to get Docker Compose is to install Docker Desktop. Docker Desktop includes Docker Compose along with Docker Engine and Docker CLI which are Compose prerequisites.

Docker Desktop is available on:

  • Linux

  • Mac

  • Windows

If you have already installed Docker Desktop, you can check which version of Compose you have by selecting About Docker Desktop from the Docker menu.

  1. Scenario two: Install the Compose plugin

    If you already have Docker Engine and Docker CLI installed, you can install the Compose plugin from the command line, by either:

    • Using Dockerโ€™s repository

    • Downloading and installing manually

  2. Scenario three: Install the Compose standalone

    You can install the Compose standalone on Linux or on Windows Server.

๐Ÿ‘‰ Install the Docker Compose plugin:

To install the Compose plugin on Linux, you can either:

  • Set up Dockerโ€™s repository on your Linux system.

  • Install Compose manually.

๐Ÿ‘‰ Install using the repository:

  1. Set up the repository. Find distro-specific instructions in:

Ubuntu | CentOS | Debian | Raspberry Pi OS | Fedora | RHEL | SLES.

  1. Update the package index, and install the latest version of Docker Compose:
  • For Ubuntu and Debian, run:
$ sudo apt-get update
$ sudo apt-get install docker-compose-plugin
  • For RPM-based distros, run:
$ sudo yum update
$ sudo yum install docker-compose-plugin
  • Verify that Docker Compose is installed correctly by checking the version.
$ docker compose version

Expected output:

Docker Compose version vN.N.N

Where vN.N.N is placeholder text standing in for the latest version.

๐Ÿ‘‰ Install the plugin manually:

To download and install the Compose CLI plugin, run:

$ DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
$ mkdir -p $DOCKER_CONFIG/cli-plugins
$ curl -SL https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose

This command downloads the latest release of Docker Compose (from the Compose releases repository) and installs Compose for the active user under $HOME directory.

To install:

  • Docker Compose for all users on your system, replace ~/.docker/cli-plugins with /usr/local/lib/docker/cli-plugins.

  • A different version of Compose, substitute v2.26.1 with the version of Compose you want to use.

  • For a different architecture, substitute x86_64 with the architecture you want.

Apply executable permissions to the binary:

$ chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose

or, if you chose to install Compose for all users:

$ sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose

Test the installation.

$ docker compose version


Docker Compose version v2.26.1

๐Ÿ‘‰ Install Compose standalone

On Linux:

To download and install Compose standalone, run:

$ curl -SL https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

Apply executable permissions to the standalone binary in the target path for the installation.

Test and execute compose commands using docker-compose.

On Windows Server:

Follow these instructions if you are running the Docker daemon and client directly on Microsoft Windows Server and want to install Docker Compose.

GitHub now requires TLS1.2. In PowerShell, run the following:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12Run PowerShell as an administrator. When asked if you want to allow this app to make changes to your device, select Yes in order to proceed with the installation.

Run the following command to download the latest release of Compose (v2.26.1):

 Start-BitsTransfer -Source "https://github.com/docker/compose/releases/download/v2.26.1/docker-compose-windows-x86_64.exe" -Destination $Env:ProgramFiles\Docker\docker-compose.exe

Test the installation.

docker-compose.exe version


Docker Compose version v2.26.1

๐Ÿ‘‰ Uninstall Docker Compose

Uninstalling Docker Compose depends on the method you have used to install Docker Compose.

  1. Uninstalling the Docker Compose CLI plugin:

To remove the Compose CLI plugin, run:

Ubuntu, Debian:

$ sudo apt-get remove docker-compose-plugin

RPM-based distros:

$ sudo yum remove docker-compose-plugin
  1. Manually installed:

If you used curl to install Compose CLI plugin, to uninstall it, run:

$ rm $DOCKER_CONFIG/cli-plugins/docker-compose
  1. Remove for all users:

Or, if you have installed Compose for all users, run:

$ rm /usr/local/lib/docker/cli-plugins/docker-compose
  1. Inspect the location of the Compose CLI plugin:

To check where Compose is installed, use:

$ docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}'

Did you find this article valuable?

Support Megha Sharma's Blog by becoming a sponsor. Any amount is appreciated!

ย