在麒麟v10服务器版上安装docker

信创,你懂的

尝试安装

先按官方centos的方法,果然报错了

果然报错了

果然报错了

虽然报错了,还是把链接附上,别使用
https://docs.docker.com/engine/install/centos/

报错信息如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 Problem 1: cannot install the best candidate for the job

- nothing provides libc.so.6(GLIBC_2.34)(64bit) needed by docker-ce-3:29.5.2-1.el10.x86_64

- nothing provides libnftables.so.1(LIBNFTABLES_1)(64bit) needed by docker-ce-3:29.5.2-1.el10.x86_64

Problem 2: cannot install the best candidate for the job

- nothing provides libc.so.6(GLIBC_2.34)(64bit) needed by docker-ce-cli-1:29.5.2-1.el10.x86_64

Problem 3: problem with installed package docker-runc-1.0.0.rc3-222.ky10.x86_64

- package containerd.io-2.2.4-1.el10.x86_64 conflicts with runc provided by docker-runc-1.0.0.rc3-222.ky10.x86_64

- package containerd.io-2.2.4-1.el10.x86_64 conflicts with runc provided by docker-runc-1.0.0.rc3-223.ky10.x86_64

- package containerd.io-2.2.4-1.el10.x86_64 conflicts with runc provided by docker-runc-1.0.0.rc3-223.p01.ky10.x86_64

- package containerd.io-2.2.4-1.el10.x86_64 conflicts with runc provided by docker-runc-1.0.0.rc3-223.p02.04.ky10.x86_64

- package containerd.io-2.2.4-1.el10.x86_64 conflicts with runc provided by docker-runc-1.0.0.rc3-229.p01.ky10.x86_64

- cannot install the best candidate for the job

(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--n obest' to use not only best candidate packages)

出现这个问题,核心原因在于:你添加的 Docker 官方源,把你的系统误认为是 CentOS 10(CentOS Stream 10)了。

为什么会报错?

看这两行:

  • needed by docker-ce-3:29.5.2-1.el10.x86_64 (.el10 代表 CentOS 10)

  • nothing provides libc.so.6(GLIBC_2.34)(64bit)

Docker 官方的 docker-ce.repo 脚本在麒麟系统上运行时,把系统识别成了 el10。于是 dnf 去下载了适配 CentOS 10 的最新版 Docker。而 CentOS 10 依赖非常新的 GLIBC 2.34,但你的麒麟 V10 底层(基于 openEuler 20.03/CentOS 8)自带的 GLIBC 版本较低,因此直接报依赖缺失。同时,它和系统自带的国产定制版 docker-runc 产生了冲突(Problem 3)。

解决

既然知道了是因为引错了“CentOS 10”的包,解决办法就是强制让 DNF 去用 CentOS 8(el8)的安装包。CentOS 8 的环境和你的麒麟 V10 完美契合。

第一步:清理错误的仓库和残留冲突

1
2
3
4
5
# 1. 删除之前错误的 repo 文件
rm -f /etc/yum.repos.d/docker-ce.repo

# 2. 卸载系统自带的、会导致冲突的旧版 docker-runc(对应 Problem 3)
dnf remove -y docker-runc podman buildah

第二步:重新添加源,并强制指定为 CentOS 8

这里推荐使用国内阿里云镜像源,速度更快。

1
2
3
4
5
6
7
8
9
# 1. 重新下载阿里云的 docker 源
curl -o /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 2. 关键一步:把源里面的 $releasever 变量强制替换为 8
sed -i 's/\$releasever/8/g' /etc/yum.repos.d/docker-ce.repo

# 3. 清理并刷新 DNF 缓存
dnf clean all
dnf makecache

第三步:安装 Docker(并允许替换冲突包)

因为麒麟系统内可能还有其他 podman 或容器遗留组件,我们在安装时加上 –allowerasing 和 –nobest,允许它自动替换旧的冲突组件。

1
dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin --allowerasing --nobest

第四步:启动并验证

1
2
3
4
5
# 启动并设置开机自启
systemctl enable --now docker

# 检查运行状态
systemctl status docker
0%