'Installing docker-compose on Amazon EC2 Linux 2. 9kb docker-compose file

First of all, let me state I'm not the most virtuous of Linux users, so bare with me... Below is a brief run-down of all the steps I took. Ultimately the question/issue is is that it seems impossible for me to get a proper docker-compose installation downloaded.

  1. Followed instructions to install docker https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html
  2. sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Tried 4 variations of the above command to try to install docker-compose. As shown in the URLs below.

  1. https://www.codegrepper.com/code-examples/php/how+to+install+docker+compose+in+ec2
  2. https://portal.cloud303.io/forum/aws-1/question/i-want-to-install-docker-compose-on-an-amazon-linux-2-ec2-instance-9
  3. https://acloudxpert.com/how-to-install-docker-compose-on-amazon
  4. https://gist.github.com/npearce/6f3c7826c7499587f00957fee62f8ee9 When typing "docker-compose", "sudo docker-compose" etc. All it will say is

"Line 1: Not: command not found".

It seems to be the issue that the docker-compose file is only 9kb in size. Because this is what I get back every time I use the above mentioned docker-compose install sequences.

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100     9  100     9    0     0     58      0 --:--:-- --:--:-- --:--:--    58

This issue is sort of addressed here: https://github.com/docker/compose/issues/6268

Where it is said that the OS is not supported or that we're running a 32bit instance, but of which seem to be strange because all the above tutorials are specifically for AWS EC2 Linux 2.

fwiw 'uname -m' returns aarch64.

So, does anyone have an idea of how to get a full-sized version of docker-compose instead of the 9kb file?

Thanks!



Solution 1:[1]

followed the link to install the docker-compose link

Basically, thee are only two steps as below:

sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

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

docker-compose version

Solution 2:[2]

Amazon Linux is "just" the OS, but compiled binaries also depend on your processor architecture. For instance, EC2 t3a series are based on x86_64 architecture wheras the new t4g types are of aarch64 (which is the reason I run into as similar issue as you and ended up here). uname -m returns that identifier, in your case apparently aarch64.

Since the docker-compose github repo contains no released binary for this architeture (as opposed to x86_64), the resolved full download URL returns a "Not found" body instead of the expected binary, thus the described error message when you try to execute it.

As you already found out, there a multiple threads which discuss this issue. The only thing that eventually worked for me was to install docker-compose manually via python's packaga manager pip. Since this approach involves a couple of compilation steps, you need to add various additional OS packages and may face other mostly dependency related errors in the process. But the following steps eventually worked for me:

uname -s -m
1> Linux aarch64
cat /etc/system-release
1> Amazon Linux release 2 (Karoo)

sudo yum install -y python37 \
    python3-devel.$(uname -m) libpython3.7-dev \
    libffi-devel openssl-devel 
# need gcc and friends
sudo yum groupinstall -y "Development Tools"
# make sure pip is up2date
sudo python3 -m pip install -U pip
python3 -m pip install docker-compose 
docker-compose --version

1> docker-compose version 1.27.4, build unknown

Hope it works for you as well. Good Luck!

Solution 3:[3]

I tried everything here mentioned, in the end, it was a problem with the symlink. The official docker page gave me the solution.

  1. sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

If it doesn't work after that command, check if you can find docker in your bin folder, e.g. with: ls /usr/local/bin/

If you can see docker-compose there, you almost made it.

  1. sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

An easy way to check if docker-compose is there and Linux able to find it, is to use `which docker-compose, also if it is linked correctly, you will get the path to docker-compose as a response.

This worked for me on a AWS EC2 instance with Linux2 as OS.

Solution 4:[4]

I faced the same issue. My configuration is T4Large - ARM64 - Ubuntu Server 20.04 LTS and I resolved using the following command

$ sudo apt install docker-compose

This will install the 1.25.0 version of docker compose which is a bit older. At the time of writing this answer the current version is 1.29.1

Another alternative is to use Docker Compose as Docker Container.

Use the following commands to run Docker Compose Container

$ sudo curl -L --fail https://raw.githubusercontent.com/linuxserver/docker-docker-compose/master/run.sh -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

This should work on any Linux distro and on architecture like x86_64, armv7l/armhf, and aarch64/armv8/arm64 if you already have docker installed.

The important point to note is, this runs compose inside a container and does not require installing python on the host system.

Docker hub reference: https://hub.docker.com/r/linuxserver/docker-compose

Solution 5:[5]

You can start from the scratch on Amazon Linux ec2 instance for installing Docker by following the step:

sudo yum update -y 

sudo amazon-linux-extras install docker 

sudo yum install docker 

sudo service docker start 

sudo usermod -a -G docker ec2-user 

Then logout from the instance and login again to verify the installation of Docker

docker info 

To install Docker-compose follow the below steps:

sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

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

docker-compose version

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Santosh Garole
Solution 2 Xander Harris
Solution 3 Anthony
Solution 4 Muhammad Tariq
Solution 5 yogesh cl