Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-compose: /usr/local/bin/docker-compose : line 1: Not: command not found

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?

like image 543
simpsons3 Avatar asked Nov 07 '19 11:11

simpsons3


1 Answers

UPDATE:

Added the following command to my answer to download the LATEST version without specifying any version number at all so the download can be scripted.

curl -L "https://github.com/docker/compose/releases/download/$(curl https://github.com/docker/compose/releases | grep -m1 '<a href="/docker/compose/releases/download/' | grep -o 'v[0-9:].[0-9].[0-9]')/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

It's a bit untidy, but it works. If you have a more elegant way than mine, ping it to me in the comments and I'll update my answer.

Just need to set the perms on the file:

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

Use the file command to validate that you pulled the correct arch for your system.

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.

like image 165
F1Linux Avatar answered Sep 17 '22 12:09

F1Linux