docker安装(CentOS8)

Centos8 安装docker

使用yum安装docker-ce:
命令:
# 1. 更新yum包到最新
yum update
# 2. 安装yum-utils(提供 yum-config-manager 功能)、同时需要安装两个devicemapper驱动依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
# 3. 设置yum源:https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 4. 安装docker
yum install -y docker-ce
# 可用yum list查看docker-ce的版本,安装指定版本只需要指定安装docker-ce-版本号即可
yum list docker-ce --showduplicates | sort -r
# 5. 验证安装
docker -v

第三步:yum会在/etc/yum.repos.d/下去找默认配置文件,然后在网上搜索
在这里插入图片描述

踩坑:

1.第四步安装docker

yum install -y docker-ce
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Docker CE Stable - x86_64                        11 kB/s |  20 kB     00:01    
error:
 problem: package docker-ce-3:19.03.4-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
  - cannot install the best candidate for the job
  - package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
  - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
  - package containerd.io-1.2.2-3.el7.x86_64 is excluded
  - package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
  - package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
  - package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

这是因为安装 docker-ce-3:19.03.4-3.el7.x86_64的需要containerd.io版本>=1.2.2-3,当前系统的containerd.io版本不够。

解决方法有三种:

1.安装更低版本的docker,是你系统的containerd.io版本支持的:

# 反序打印docker-ce的
yum list docker-ce --showduplicates | sort -r 

在这里插入图片描述

# 安装指定版本
yum -y install  docker-ce-18.06.0.ce-3.el7 

2.安装命令后面追加 --skip-broken(跳过此项安装) 或者 --nobest (使用最佳安装包) 进行安装:

yum install -y docker-ce --nobest
# 或者
dnf -y  install docker-ce --nobest

3.更新containerd.io,再安装docker

yum list containerd.io --showduplicates | sort -r 

在这里插入图片描述

# 可以看到这里containerd.io并没有支持的版本(>1.2.2-3),所以选择从外部直接下载安装包:网址是https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
# 		- 下载的方法有两种:使用win下载再使用工具传入linux系统(比如xshell的xFTP)
#		 - 使用wget download_url   指令直接使用下载链接在linux下载目标文件

在这里插入图片描述

#下载的安装包是.rpm文件,使用rpm安装前要先卸载原containerd.io再安装
rpm -e containerd.io
rpm -ivh containerd.io-1.2.4-3.1.el7.x86_64.rpm

如果安装时遇到
worning:containerd.io-1.2.4-3.1.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 621e9f35: NOKEY
错误:依赖检测失败:
runc 与 containerd.io-1.2.4-3.1.el7.x86_64 冲突
runc 被 containerd.io-1.2.4-3.1.el7.x86_64 取代

# 删除runc及其依赖后重装即可
yum erase runc  (erase等价与remove)
rpm -ivh containerd.io-1.2.4-3.1.el7.x86_64.rpm

# 然后安装docker-ce:
yum install -y docker-ce

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值