34

i'm trying to install Docker-compose on my Raspberry Pi 3+ which installed Raspbian buster. I followed instruction on docker.com. After I entered command : sudo curl -L https://github.com/docker/compose/releases/download/1.20.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose. It show a table for downloading

Result

It seems nothing downloaded, just have a file docker-compose saved in /usr/local/bin/docker-compose. When I opened it, it empty. Then I enter command docker-compose -v, it displayed error /usr/local/bin/docker-compose : line 1: Not: command not found. Anyone have solution?

simpsons3
  • 880
  • 1
  • 11
  • 29

2 Answers2

83

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.

F1Linux
  • 3,580
  • 3
  • 25
  • 24
28

This is because on a raspberry pi the url part of the command results in

https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-armv7l

Looking at the latest stable release at https://github.com/docker/compose/releases/tag/1.24.1 you can see there is no download for the armv7l architecture so the file is empty because there is nothing to download.

Will update answer once I figured out how to install docker-compose on Raspian.

Edit:

Via apt-get. Note: Currently (Nov. 8 2019) this installs version 1.21 which is not the latest available.

sudo apt-get install docker-compose

Via pip3. (Installs latest)

sudo apt-get install python3-pip
sudo pip3 install docker-compose

And then restart your system with

sudo shutdown -r
Andrew Diamond
  • 6,295
  • 1
  • 15
  • 33
Sascha
  • 641
  • 7
  • 8
  • Thank for rep. I've try install by 2 ways, but it did't work, it show that ```sudo: docker-compose: command not found```. But when i enter command without ```sudo```, terminal display ```bash: /usr/local/bin/docker-compose: permission denied```. I go to this folder and it is empty. It seems that path to docker-compose is not exactly, but i don't know where is real path of docker compose. – simpsons3 Nov 09 '19 at 01:46
  • If you are still early in the setup I'd recommend simply reinstalling Raspian since your modifications earlier probably broke the PATH variable. – Sascha Nov 26 '19 at 10:58
  • yea, I did reinstall Raspian, and it worked. I forgot to update for you XD – simpsons3 Nov 26 '19 at 17:03