在 RHEL 7 Linux 服务器上安装 Docker 时出现问题

在 RHEL 7 Linux 服务器上安装 Docker 时出现问题

我最近越来越多地遇到这个问题,最后需要一些帮助,因为我完全陷入困境。

我刚刚访问了 RHEL EC2 Linux 服务器,并且只是尝试安装 Docker。这个过程最近非常痛苦。尝试遵循网上提到的流程时出现大量 404 HTTP Not Found 错误

根据https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html,您只需运行以下两个命令之一即可:

  • sudo amazon-linux-extras 安装 docker
  • 须藤 yum 安装 docker

但是,这些命令都不起作用,如下面的输出所示:

[root@d8de679d27f2454 myuser]# sudo amazon-linux-extras install docker
sudo: amazon-linux-extras: command not found
[root@d8de679d27f2454 myuser]# yum install docker
Loaded plugins: amazon-id, search-disabled-repos
No package docker available.
Error: Nothing to do
[root@d8de679d27f2454 myuser]#

以下是我尝试做的事情的列表:

第一次尝试(关于:https://stackoverflow.com/questions/53918841/how-to-install-docker-on-amazon-linux2

建议的第二个答案是您可以运行以下命令:

sudo yum update -y
sudo yum -y install docker

但是,这也不起作用,如下面的输出所示:

[root@d8de679d27f2454 myuser]# yum update -y
Loaded plugins: amazon-id, search-disabled-repos
No packages marked for update
[root@d8de679d27f2454 myuser]# yum -y install docker
Loaded plugins: amazon-id, search-disabled-repos
No package docker available.
Error: Nothing to do
[root@d8de679d27f2454 myuser]# 

第二次尝试: 安装通过get.docker.com

运行时curl https://get.docker.com | bash,这也不起作用

在此输入图像描述

第三次尝试https://computingforgeeks.com/install-docker-ce-on-rhel-7-linux/

本文的部分内容建议运行以下两个命令:

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

然而,这也不起作用:

# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: amazon-id, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

https://download.docker.com/linux/rhel/7/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.



 One of the configured repositories failed (Docker CE Stable - x86_64),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=docker-ce-stable ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable docker-ce-stable
        or
            subscription-manager repos --disable=docker-ce-stable

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=true

failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://download.docker.com/linux/rhel/7/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

cat /etc/os-release这是我的命令的输出

NAME="Red Hat Enterprise Linux Server"
VERSION="7.9 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.9"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.9 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.9:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

任何帮助将不胜感激。此时安装 docker 似乎几乎是不可能的。

答案1

将 /etc/yum.repos.d/ 中的 repo 文件替换为以下文件:

https://download.docker.com/linux/centos/docker-ce.repo

您下载的版本仅适用于运行 s390x 系统的情况。 Docker 对于如何构建 yum 存储库有点愚蠢,这一直让人们感到困惑。

证明:查看目录中rhel/7 目录与 中的相比centos/7 目录。 rhel 目录仅包含 s390x 和源代码,而 CentOS 有一个 x86_64 目录,其中包含软件包和存储库元数据。

答案2

sudo:amazon-linux-extras:找不到命令

Meanamazon-linux-extras尚未安装,您需要安装它:

sudo yum install -y amazon-linux-extras

Docker 在 Extras 中可用:

Docker 仅在附加功能中

Docker 的软件包只能通过 extras 获得,并且默认情况下处于启用状态。当 Docker 新版本发布时,将仅提供对最新稳定软件包的支持。

要安装泊坞窗:

sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user

亚马逊:安装 Docker

答案3

答案4

创造一个/etc/yum.repos.d/docker.repo拥有

[docker]
name=docker
gpgcheck=1
enabled=1
baseurl=https://download.docker.com/linux/centos/7/x86_64/stable

请注意,似乎没有有效的 RHEL docker 存储库,但可以使用 centos docker 存储库

我没有详细说明支持 nvidia docker 的额外存储库(见下文),但 nvidia docker 网站上发布的那些说明是有效的。

然后,在 RHEL 7.9 x86-64 中,以下内容对我有用

yum install
 containerd.io-1.4.3-3.1.el7.x86_64.rpm
 docker-ce-20.10.5-3.el7.x86_64.rpm
 docker-ce-cli-20.10.5-3.el7.x86_64.rpm
 docker-ce-rootless-extras-20.10.5-3.el7.x86_64.rpm
 libnvidia-container1-1.3.3-1.x86_64.rpm
 libnvidia-container-tools-1.3.3-1.x86_64.rpm
 nvidia-container-runtime-3.4.2-1.x86_64.rpm
 nvidia-container-toolkit-1.4.2-2.x86_64.rpm
 nvidia-docker2-2.5.0-1.noarch.rpm

systemctl --now enable docker
systemctl restart docker
systemctl status docker
docker -v
  Docker version 20.10.5, build 55c4c88

这些是可用的指定 gpg 密钥

gpgkey-docker-ce-centos
gpgkey-docker-ce-rhel
gpgkey-libnvidia-container
gpgkey-nvidia-container-runtime
gpgkey-nvidia-docker

Docker 与 Nvidia 可以在 RHEL 7.9 中工作。

相关内容