简体   繁体   English

在 Amazon EC2 上安装 docker-compose Linux 2. 9kb docker-compose 文件

[英]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 bear with me... Below is a brief run-down of all the steps I took.首先,让我 state 我不是 Linux 用户中最有道德的人,所以请耐心等待……下面是我采取的所有步骤的简要说明。 Ultimately the question/issue is is that it seems impossible for me to get a proper docker-compose installation downloaded.最终的问题是,我似乎不可能下载正确的 docker-compose 安装。

  1. Followed instructions to install docker https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html按照说明安装 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 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.尝试了上述命令的 4 个变体来尝试安装 docker-compose。如下面的 URL 所示。

  1. https://www.codegrepper.com/code-examples/php/how+to+install+docker+compose+in+ec2 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 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 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 https://gist.github.com/npearce/6f3c7826c7499587f00957fee62f8ee9当输入“docker-compose”、“sudo docker-compose”等时,它只会说

"Line 1: Not: command not found". “第 1 行:不是:找不到命令”。

It seems to be the issue that the docker-compose file is only 9kb in size.问题似乎是 docker-compose 文件只有 9kb。 Because this is what I get back every time I use the above mentioned docker-compose install sequences.因为这是我每次使用上述 docker-compose 安装序列时得到的结果。

% 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这个问题在这里得到了解决: 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.哪里说操作系统不受支持,或者我们正在运行一个 32 位实例,但其中似乎很奇怪,因为以上所有教程都是专门针对 AWS EC2 Linux 2.

fwiw 'uname -m' returns aarch64. fwiw 'uname -m' 返回 aarch64。

So, does anyone have an idea of how to get a full-sized version of docker-compose instead of the 9kb file?那么,有没有人知道如何获得 docker-compose 的完整版本而不是 9kb 文件?

Thanks!谢谢!

followed the link to install the docker-compose link按照链接安装 docker-compose 链接

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

Amazon Linux is "just" the OS, but compiled binaries also depend on your processor architecture. Amazon Linux“只是”操作系统,但编译后的二进制文件还取决于您的处理器架构。 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).例如,EC2 t3a系列基于x86_64架构,而新的t4g类型是aarch64 (这就是我遇到与您类似的问题并最终在这里结束的原因)。 uname -m returns that identifier, in your case apparently aarch64 . uname -m返回该标识符,在您的情况下显然是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.由于 docker-compose github repo 不包含此架构的已发布二进制文件(与x86_64相对),因此解析的完整下载 URL 返回“未找到”正文而不是预期的二进制文件,因此在您尝试执行时会出现所描述的错误消息.

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 .最终对我有用的唯一方法是通过 python 的 packaga 管理器pip手动安装 docker -compose 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.由于此方法涉及几个编译步骤,因此您需要添加各种额外的 OS 包,并且在此过程中可能会遇到其他主要与依赖相关的错误。 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!祝你好运!

You can start from the scratch on Amazon Linux ec2 instance for installing Docker by following the step:您可以按照以下步骤从头开始在Amazon Linux ec2实例上安装 Docker:

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的安装

docker info 

To install Docker-compose follow the below steps:要安装 Docker-compose,请按照以下步骤操作:

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

Installing Docker-Compose in EC2 instance follow below steps按照以下步骤在 EC2 实例中安装 Docker-Compose

1st command : # sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose第一条命令:# sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/ bin/docker-compose

2nd command : # sudo chmod +x /usr/local/bin/docker-compose第二条命令:# sudo chmod +x /usr/local/bin/docker-compose

3rd command : # ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose第三条命令:# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

4th Command to verify docker compose : # docker-compose version第 4 个命令验证 docker 组成:#docker-compose 版本

It will install latest version of docker-compose. 3rd command is necessary.它将安装最新版本的 docker-compose。第三条命令是必需的。

I faced the same issue.我遇到了同样的问题。 My configuration is T4Large - ARM64 - Ubuntu Server 20.04 LTS and I resolved using the following command我的配置是T4Large - ARM64 - Ubuntu Server 20.04 LTS ,我使用以下命令解决

$ sudo apt install docker-compose

This will install the 1.25.0 version of docker compose which is a bit older.这将安装1.25.0版本的1.25.0 compose,它1.25.0 At the time of writing this answer the current version is 1.29.1在撰写此答案时,当前版本为1.29.1

Another alternative is to use Docker Compose as Docker Container .另一种选择是使用Docker Compose作为Docker Container

Use the following commands to run Docker Compose Container使用以下命令运行 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.如果您已经安装了armv7l/armhf ,这应该适用于任何 Linux 发行版和x86_64armv7l/armhfaarch64/armv8/arm64等架构。

The important point to note is, this runs compose inside a container and does not require installing python on the host system.需要注意的重要一点是,这在容器内运行,不需要在主机系统上安装 python。

Docker hub reference: https://hub.docker.com/r/linuxserver/docker-compose Docker 集线器参考: https : //hub.docker.com/r/linuxserver/docker-compose

I tried everything here mentioned, in the end, it was a problem with the symlink.我尝试了这里提到的所有内容,最后,这是符号链接的问题。 The official docker page gave me the solution.官方 docker 页面给了我解决方案。

  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, eg with: ls /usr/local/bin/如果在该命令之后它不起作用,请检查您是否可以在 bin 文件夹中找到 docker,例如: ls /usr/local/bin/

If you can see docker-compose there, you almost made it.如果你能在那里看到 docker-compose,你几乎就成功了。

  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.检查 docker-compose 是否存在并且 Linux 能够找到它的一种简单方法是使用 `which docker-compose,如果链接正确,您将获得 docker-compose 的路径作为响应。

This worked for me on a AWS EC2 instance with Linux2 as OS.这在以 Linux2 作为操作系统的 AWS EC2 实例上对我有用。

This will do everything you need.这将做你需要的一切。 Cut.切。 paste.粘贴。 done.完毕。

cat ec2-al2-docker-compose.sh

#the following script will install docker and docker compose on amazon linux 2

# run this script then 
# sudo docker ps; docker-compose up 
# note docker-compose up doesnt use sudo

sudo yum update -y
sudo yum install docker git -y
sudo usermod -a -G docker ec2-user
id ec2-user
newgrp docker
sudo yum install python3-pip -y
sudo pip3 install docker-compose
sudo systemctl enable docker.service
sudo systemctl start docker.service

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM