Installing docker compose v2 release as a plugin in Linux


After recently installing docker Linux machine, I found out that docker compose v2 is out and the installation process is different. Since Docker Desktop is not available for Linux, we need to install it from the project release page


The Linux installation docs explain how to install a particular version of the docker compose plugin. That is sufficient when you are doing those operations manually; but may potentially install an old version, specially if using as part of a script that runs automatically.

Installing the latest version always

If instead, we want to install the binary docker-compose-linux-x86_64 from latest version, we need to interact with the GitHub API to find the binary’s download URL. This is where jq comes handy, as it allows to filter and extract data from JSON.

  1. Create ~/.docker/cli-plugins folder if it doesn’t exist
mkdir -p ~/.docker/cli-plugins/
  1. We start interacting with the API, by getting the JSON information from the latest release and presenting it nice in the console with jq
curl -s | jq

The output from the above command should be similar to:

curl -s
| jq
  "url": "",
  "assets_url": "",
  "assets": [
      "url": "",
	  "name": "docker-compose-darwin-aarch64",
      "browser_download_url": ""
  "tarball_url": "",
  "zipball_url": "",
  1. Using the output above, we see that each asset object contains a name and a browser_download_url properties. Then, we can filter with jq to return the browser_download_url based on the asset’s name that we want to install (docker-compose-linux-x86_64 in this exercise).
curl -s | jq -r ".assets[] | select(.name | contains(\"docker-compose-linux-x86_64\")) | .browser_download_url"

Although this narrows the search significantly, the above command outputs 2 URLs as a result, one for the compose binary and the other for its sha256 manifest file.

  1. If we want a single URL output, we can filter out the *.sha256 file and the final command looks like:
 $URL=$(curl -s | jq -r ".assets[] | select(.name | contains(\"linux-x86_64\")) | select(.name | contains(\"sha256\") | not) | .browser_download_url")

Then, we can proceed with the same steps as the specific-version installation:

  1. Download the plugin
curl -SL $URL -o ~/.docker/cli-plugins/docker-compose
  1. Apply executable permissions so that docker can run your binary
chmod +x ~/.docker/cli-plugins/docker-compose

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.