UPDATE: 20230829
Fixed Automating download of latest release of docker-compose
Last update of curl
apparently didn't like my script to automate the download of the latest release of docker-compose
. So here's the re-jiggered script which is tested and known to work with Ubuntu 22.04.3. Since GitHub doesn't like IPv6, I forced IPv4 in the
curl
command.
Obviously if not using Ubuntu, change the target paths for the download accordingly...
#!/bin/bash
DOCKERCOMPOSECURRENTRELEASENUMBER="$(curl -4 -k --http2 https://github.com/docker/compose/releases | grep -m1 '<a href="/docker/compose/releases/download/' | awk -F/ '{print $6}')"
if [[ ! -f /usr/local/bin/docker-compose ]]; then
curl -L "https://github.com/docker/compose/releases/download/"$DOCKERCOMPOSECURRENTRELEASENUMBER"/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
fi
Intro:
Although docker-compose
can be installed from a repo per the accepted answer, apt-cache show docker-compose
reveals that as of 20211201 the repo version is only v1.25; about 2 years behind the current v2.1.1 release. In order to take advantage of more modern docker file versions, I needed to get the Github download working.
Short Answer:
The Docker documentation for Docker-Compose is WRONG. They forgot to preface the version number in the command with a "v"; consequently the download fails. Apparently this has been wrong for ages...
Longer Answer:
I ran the below command from the Docker-Compose documentation, and substituted the version "2.1.1" for "1.29.1" per Docker's guidance:
To install a different version of Compose, substitute 1.29.2 with the
version of Compose you want to use.
sudo curl -L "https://github.com/docker/compose/releases/download/2.1.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
The resulting download was 9 KB for a 23 MB binary. Clearly the link was bogus. So I went to the root of the address used in the command "https://github.com/docker/compose/releases" and right-clicked on the version of Docker-Compose that I wanted and chose "Copy Link Address"
This revealed the link Docker was telling folks to use didn't have a "v" prefaced before the version number in the https://
address part of the command.
Solution:
Preface a "v" before the version number you want in the link as below and the command executes successfully:
sudo curl -L "https://github.com/docker/compose/releases/download/v2.1.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
BTW, I too was downloading docker-compose
for a Raspberry Pi using the aarch64 binary for Ubuntu 20.04 LTS. However, the missing "v" fix for the broken download address should work for any platform.