下面是详细的攻略:
CentOS版本问题安装Docker报错的解决方案
问题描述
在CentOS系统下安装Docker时,可能会出现如下报错:
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
epel/x86_64/metalink | 27 kB 00:00:00
epel | 4.7 kB 00:00:00
(1/4): extras/7/x86_64/primary_db | 152 kB 00:00:00
(2/4): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(3/4): epel/x86_64/primary_db | 6.7 MB 00:00:00
(4/4): extras/7/x86_64/other_db | 77 kB 00:00:00
Metadata Cache Created
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* epel: mirrors.aliyun.com
* extras: mirrors.tencentyun.com
* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:18.06.1.ce-3.el7 will be installed
--> Processing Dependency: docker-ce-cli = 18.06.1.ce-3.el7 for package: docker-ce-18.06.1.ce-3.el7.x86_64
--> Processing Dependency: container-selinux >= 2.9 for package: docker-ce-18.06.1.ce-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.68-1.el7 will be installed
---> Package docker-ce-cli.x86_64 0:18.06.1.ce-3.el7 will be installed
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: docker-ce-cli-18.06.1.ce-3.el7.x86_64
--> Running transaction check
---> Package containerd.io.x86_64 1:1.2.5-3.1.el7 will be installed
--> Processing Dependency: cri-tools >= 1.12.0-0 for package: 1:containerd.io-1.2.5-3.1.el7.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: 1:containerd.io-1.2.5-3.1.el7.x86_64
--> Processing Dependency: pigz for package: 1:containerd.io-1.2.5-3.1.el7.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-ce-cli-18.06.1.ce-3.el7.x86_64
--> Running transaction check
---> Package cri-tools.x86_64 0:1.13.0-0.alpha.0.1.el7 will be installed
---> Package pigz.x86_64 0:2.3.3-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
docker-ce x86_64 18.06.1.ce-3.el7 docker-ce-stable 21 M
Installing for dependencies:
container-selinux noarch 2:2.68-1.el7 extras 29 k
containerd.io x86_64 1:1.2.5-3.1.el7 docker-ce-stable 22 M
cri-tools x86_64 1.13.0-0.alpha.0.1.el7 extras 8.4 M
docker-ce-cli x86_64 18.06.1.ce-3.el7 docker-ce-stable 15.4 M
pigz x86_64 2.3.3-1.el7 extras 76 k
Transaction Summary
========================================================================================================================================
Install 1 Package (+5 Dependent packages)
Total size: 67 M
Installed size: 291 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-cli-18.06.1.ce-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-cli-18.06.1.ce-3.el7.x86_64.rpm is not installed
(1/6): container-selinux-2.68-1.el7.noarch.rpm | 29 kB 00:00:00
(2/6): cri-tools-1.13.0-0.alpha.0.1.el7.x86_64.rpm | 8.4 MB 00:00:00
(3/6): docker-ce-18.06.1.ce-3.el7.x86_64.rpm | 21 MB 00:00:00
(4/6): docker-ce-cli-18.06.1.ce-3.el7.x86_64.rpm | 15 MB 00:00:00
(5/6): containerd.io-1.2.5-3.1.el7.x86_64.rpm | 22 MB 00:00:00
(6/6): pigz-2.3.3-1.el7.x86_64.rpm | 76 kB 00:00:00
----------------------------------------------------------------------------------------------------------------------------------------
Total 68 MB/s | 67 MB 00:00:00
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
From : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:container-selinux-2.68-1.el7.noarch 1/6
Installing : pigz-2.3.3-1.el7.x86_64 2/6
Installing : 1:containerd.io-1.2.5-3.1.el7.x86_64 3/6
Installing : cri-tools-1.13.0-0.alpha.0.1.el7.x86_64 4/6
Installing : docker-ce-cli-18.06.1.ce-3.el7.x86_64 5/6
Installing : docker-ce-18.06.1.ce-3.el7.x86_64 6/6
Verifying : container-selinux-2.68-1.el7.noarch 1/6
Verifying : 1:containerd.io-1.2.5-3.1.el7.x86_64 2/6
Verifying : pigz-2.3.3-1.el7.x86_64 3/6
Verifying : cri-tools-1.13.0-0.alpha.0.1.el7.x86_64 4/6
Verifying : docker-ce-cli-18.06.1.ce-3.el7.x86_64 5/6
Verifying : docker-ce-18.06.1.ce-3.el7.x86_64 6/6
Installed:
docker-ce.x86_64 0:18.06.1.ce-3.el7
Dependency Installed:
container-selinux.noarch 2:2.68-1.el7 containerd.io.x86_64 1:1.2.5-3.1.el7 cri-tools.x86_64 0:1.13.0-0.alpha.0.1.el7
docker-ce-cli.x86_64 0:18.06.1.ce-3.el7 pigz.x86_64 0:2.3.3-1.el7
Complete!
Failed to start docker.
解决方案
该问题可能由于使用了错误的CentOS版本导致。为了解决这个问题,我们需要执行以下几个步骤。
步骤 1:查看CentOS版本
cat /etc/redhat-release
这应该会输出你当前的CentOS版本。
步骤 2:根据CentOS版本下载适当的docker-ce安装包
进入官方Docker文档,查找并下载适合你CentOS版本的docker-ce安装包。
例如,如果你使用的是CentOS 7,你应该下载docker-ce-18.06.1.ce-3.el7.x86_64.rpm
文件。
步骤 3:安装docker-ce
使用以下命令安装docker-ce:
sudo yum install /path/to/package/docker-ce-cli-18.06.1.ce-3.el7.x86_64.rpm \
/path/to/package/docker-ce-18.06.1.ce-3.el7.x86_64.rpm \
/path/to/package/containerd.io-1.2.5-3.1.el7.x86_64.rpm
请注意,以上命令中的路径应该指向你在步骤 2 中下载的docker-ce安装包。
示例
以下是一个示例,假设我使用的是CentOS 7。我会执行以下命令:
cat /etc/redhat-release
这应该会输出以下内容:
CentOS Linux release 7.9.2009 (Core)
基于这个版本,我应该下载docker-ce-18.06.1.ce-3.el7.x86_64.rpm
文件。
我使用以下命令将下载的安装包放到我的用户目录下:
mkdir ~/packages
cp docker-ce-18.06.1.ce-3.el7.x86_64.rpm ~/packages/
最后,我使用以下命令安装docker-ce:
sudo yum install ~/packages/docker-ce-cli-18.06.1.ce-3.el7.x86_64.rpm \
~/packages/docker-ce-18.06.1.ce-3.el7.x86_64.rpm \
~/packages/containerd.io-1.2.5-3.1.el7.x86_64.rpm
这应该会安装docker-ce并解决报错问题。
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:CentOS版本问题安装Docker报错的解决方案 - Python技术站