Centos7 安装Docker步骤及报错信息(不敢说最全,但是很全)

一、操作系统要求:

  1. 要安装Docker Engine,您需要CentOS 7及以上的维护版本。存档版本不受支持或测试。
  2. 必须启用centos临时存储库。默认情况下,此存储库已启用,但如果已禁用,则需要重新启用它。
  3. 建议使用overlay2存储驱动程序。

二、安装步骤

1、卸载旧版本
Docker的旧版本被称为Docker或Docker引擎。如果安装了这些,请卸载它们以及相关的依赖项。

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

如果 yum 报告未安装这些软件包,则可以。
2、安装一些必要的系统工具
安装所需的软件包。 yum-utils 提供了 yum-config-manager 应用,并 device-mapper-persistent-data和 lvm2 由需要 devicemapper 存储驱动程序。

 yum install -y yum-utils device-mapper-persistent-data lvm2
  • 这一步如果报错Could not retrieve mirrorlist http://mirrorlist.centos.org/,

在这里插入图片描述
出现这个错误是因为你使用的 CentOS 7 仓库已经被归档,当前的镜像地址无法找到所需的文件。CentOS 7 的官方支持已经结束,部分仓库已被移至归档库。这导致了你的 yum 命令无法找到所需的元数据文件。CentOS 7 的官方仓库在 2024 年 6 月 30 日之后已经停止维护。因此,使用最新的 CentOS 7 官方仓库可能会遇到问题。则如下解决:
遇到以上问题笔者建议如下解决方案:

  • 进入/etc/yum.repos.d目录下找到 CentOS-Base.repo

  • 执行: cp CentOS-Base.repo CentOS-Base.repo.backup

  • vi CentOS-Base.repo
    将原内容修改为:

CentOS-Base.repo

The mirror system uses the connecting IP address of the client and the

update status of each mirror to pick mirrors that are updated to and

geographically close to the client. You should use this for CentOS updates

unless you are manually picking other mirrors.

If the mirrorlist= does not work for you, as a fall back you can try the

remarked out baseurl= line instead.

[base]
name=CentOS-KaTeX parse error: Expected 'EOF', got '#' at position 19: …easever - Base #̲mirrorlist=http…releasever&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=os&infra=infra
#baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / o s / releasever/os/ releasever/os/basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-KaTeX parse error: Expected 'EOF', got '#' at position 22: …ever - Updates #̲mirrorlist=http…releasever&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=updates&in…infra
#baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / u p d a t e s / releasever/updates/ releasever/updates/basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-KaTeX parse error: Expected 'EOF', got '#' at position 21: …sever - Extras #̲mirrorlist=http…releasever&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=extras&inf…infra
# b a s e u r l = h t t p : / / m i r r o r . c e n t o s . o r g / c e n t o s / baseurl=http://mirror.centos.org/centos/ baseurl=http://mirror.centos.org/centos/releasever/extras/KaTeX parse error: Expected 'EOF', got '#' at position 11: basearch/ #̲baseurl=http://…basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-KaTeX parse error: Expected 'EOF', got '#' at position 19: …easever - Plus #̲mirrorlist=http…releasever&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=centosplus…infra
#baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / c e n t o s p l u s / releasever/centosplus/ releasever/centosplus/basearch/
#baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

wq保存后,执行如下命令:

sudo yum clean all
sudo yum makecache
重新安装后显示成功:

在这里插入图片描述
在这里插入图片描述

3、添加软件源信息
源1:(官方推荐)

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

源2:(阿里云源)

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4、更新 yum 缓存

yum makecache fast

5、安装 Docker-CE

yum -y install docker-ce
  • 如果安装时报错:
[root@192 samve]# yum -y install docker-ce
上次元数据过期检查:0:03:23 前,执行于 2022年12月21日 星期三 08时50分03秒。
错误:
 问题: problem with installed package buildah-1:1.27.0-2.module_el8.7.0+1216+b022c01d.x86_64
 - package buildah-1:1.27.0-2.module_el8.7.0+1216+b022c01d.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1:1.27.0-2.module_el8.7.0+1196+721f4eb0.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1:1.24.2-2.module_el8.7.0+1106+45480ee0.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1.24.0-0.7.module_el8.6.0+944+d413f95e.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1:1.23.1-2.module_el8.6.0+954+963caf36.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1.22.3-2.module_el8.6.0+926+8bef8ae7.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1.22.3-2.module_el8.5.0+911+f19012f9.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1.22.3-1.module_el8.5.0+901+79ce9cba.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1.22.0-2.module_el8.5.0+890+6b136101.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1.22.0-2.module_el8.5.0+877+1c30e0c9.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed
 - package buildah-1.22.0-0.2.module_el8.5.0+874+6db8bee3.x86_64 requires runc >= 1.0.0-26, but none of the providers can be insta
  • 42
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

encoding-console

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值