银河麒麟 V10 SP3 安装 Docker CE + Docker Compose(实战成功版)

98 阅读4分钟

银河麒麟 V10 SP3 安装 Docker CE + Docker Compose(实战成功版)

适用系统: Kylin Linux Advanced Server V10 SP3 (Halberd)

Kernel:4.19.90-89.11.v2401.ky10.x86_64

架构:x86_64

目标: 在「银河麒麟 Kylin Linux Advanced Server V10 SP3(Halberd)」上安装【尽可能新的 / 最新的 Docker 环境】

一、背景说明(非常重要)

银河麒麟 V10 并非官方 Docker 支持发行版,直接使用最新 Docker RPM 会遇到:

  • ❌ GLIBC 版本不匹配(GLIBC_2.34)
  • ❌ 阿里云 docker-ce 镜像 403 / checksum 错误
  • ❌ docker-compose-plugin 安装失败

正确策略:

使用 CentOS 8 (el8) 兼容版本 Docker CE + 官方 docker-compose 二进制

二、安装前环境检查

1️⃣ 确认系统版本

nkvers

示例输出(关键点):

Kylin Linux Advanced Server release V10 SP3 2403
Kernel: 4.19.x

2️⃣ 检查是否已安装 Docker / Podman

docker -v
-bash: docker:未找到命令
rpm -qa | grep -E "docker|podman|containerd"

示例:

docker-runc-1.0.0.rc3-222.ky10.x86_64
podman-0.10.1-8.ky10.x86_64

移除podman和docker-runc

yum remove -y podman docker-runc

⚠️ Podman 不影响 Docker 安装,可保留

三、配置 Docker 官方仓库(el8)

1️⃣ 安装 dnf 插件

dnf install -y dnf-plugins-core

[root@DevServer tmp]# dnf install -y dnf-plugins-core
Last metadata expiration check: 0:05:32 ago on 20260104日 星期日 151925秒.
Package dnf-plugins-core-4.0.17-3.ky10.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!

2️⃣ 添加 Docker CE 官方仓库(阿里云镜像)

dnf config-manager --add-repo \
  https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

[root@DevServer tmp]# dnf config-manager --add-repo \
>   https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
添加仓库自:https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

说明: 麒麟 V10 ≈ RHEL 8 系,使用 centos/8 仓库

四、安装 Docker CE(关键步骤)

❌ 不要直接安装最新版

最新版会报错:

nothing provides GLIBC_2.34

✅ 正确做法:安装 el8 兼容稳定版

dnf install -y docker-ce-26.1.3 docker-ce-cli-26.1.3 \
  --setopt=install_weak_deps=False

执行报错:


[root@DevServer tmp]# dnf install -y docker-ce-26.1.3 docker-ce-cli-26.1.3 \
>   --setopt=install_weak_deps=False
Last metadata expiration check: 0:00:33 ago on 20260104日 星期日 152727秒.
No match for argument: docker-ce-26.1.3
No match for argument: docker-ce-cli-26.1.3
Error: Unable to find a match: docker-ce-26.1.3 docker-ce-cli-26.1.3

解决方案:

执行命令:

第一步:
rm -f /etc/yum.repos.d/docker-ce.repo

第二步:
cat > /etc/yum.repos.d/docker-ce-el8.repo << 'EOF'
[docker-ce-stable]
name=Docker CE Stable - EL8
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/8/x86_64/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
EOF

第三步:
dnf clean all && dnf makecache

第四步:
dnf list docker-ce --showduplicates


最后一步,再次执行
dnf install -y docker-ce-26.1.3 docker-ce-cli-26.1.3 \
  --setopt=install_weak_deps=False

[root@DevServer tmp]# dnf install -y docker-ce-26.1.3 docker-ce-cli-26.1.3 \
>   --setopt=install_weak_deps=False
Last metadata expiration check: 0:04:55 ago on 2026年01月04日 星期日 15时41分15秒.
Dependencies resolved.
=================================================================================================================================================================
 Package                                Architecture                    Version                                  Repository                                 Size
=================================================================================================================================================================
Installing:
 docker-ce                              x86_64                          3:26.1.3-1.el8                           docker-ce-stable                           27 M
 docker-ce-cli                          x86_64                          1:26.1.3-1.el8                           docker-ce-stable                          7.8 M

Transaction Summary
=================================================================================================================================================================
Install  2 Packages

Total download size: 35 M
Installed size: 136 M
Downloading Packages:
(1/2): docker-ce-cli-26.1.3-1.el8.x86_64.rpm                                                                                     4.4 MB/s | 7.8 MB     00:01
(2/2): docker-ce-26.1.3-1.el8.x86_64.rpm                                                                                         8.4 MB/s |  27 MB     00:03
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                             11 MB/s |  35 MB     00:03
Docker CE Stable - EL8                                                                                                            18 kB/s | 1.6 kB     00:00
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://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                         1/1
  Installing       : docker-ce-cli-1:26.1.3-1.el8.x86_64                                                                                                     1/2
  Running scriptlet: docker-ce-cli-1:26.1.3-1.el8.x86_64                                                                                                     1/2
  Installing       : docker-ce-3:26.1.3-1.el8.x86_64                                                                                                         2/2
  Running scriptlet: docker-ce-3:26.1.3-1.el8.x86_64                                                                                                         2/2
  Verifying        : docker-ce-3:26.1.3-1.el8.x86_64                                                                                                         1/2
  Verifying        : docker-ce-cli-1:26.1.3-1.el8.x86_64                                                                                                     2/2

Installed:
  docker-ce-3:26.1.3-1.el8.x86_64                                               docker-ce-cli-1:26.1.3-1.el8.x86_64

Complete!

参数说明:
参数作用
docker-ce-26.1.3el8 可用稳定版
--setopt=install_weak_deps=False跳过 docker-compose-plugin

⚠️ docker-compose-plugin 在国产系统上经常 403,不影响 Docker 本体

五、启动并验证 Docker

1️⃣ 启动并设置开机自启

systemctl enable docker
systemctl start docker

2️⃣ 验证 Docker 安装成功

docker -v

示例输出:

Docker version 26.1.3, build b72abbb
实际执行日志:

[root@DevServer tmp]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@DevServer tmp]# systemctl start docker
[root@DevServer tmp]# docker -v
Docker version 26.1.3, build b72abbb

3️⃣ Docker 用户权限(强烈推荐)

避免每次都 sudo docker

sudo usermod -aG docker xxxx_user

重新登录后生效:

exit
ssh xxxx_user@server

测试:

docker ps

ssh实际执行日志:


[root@DevServer tmp]# sudo usermod -aG docker xxxx_user
[root@DevServer tmp]#

切用户xxxx_user

[xxxx_user@DevServer ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[xxxx_user@DevServer ~]$ docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    1b44b5a3e06a   4 months ago   10.1kB
[xxxx_user@DevServer ~]$

六、安装 Docker Compose(推荐方式)

❌ 不推荐方式

  • dnf install docker-compose-plugin
  • 原因:阿里云镜像 403 / 校验失败

✅ 推荐方式(最终成功方案)

使用 官方二进制版本 Docker Compose v2

curl -L https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-linux-x86_64 \
  -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

下载失败:

自行在github中下载,然后将下载文件上传到"/usr/local/bin/"目录。
下载地址:https://github.com/docker/compose/releases?expanded=true&page=5&q=v2.27.0

ssh实际执行日志:


[root@DevServer tmp]# docker -v
Docker version 26.1.3, build b72abbb
[root@DevServer tmp]# curl -L https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-linux-x86_64 \
>   -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 49 60.0M   49 30.0M    0     0  16076      0  1:05:19  0:32:36  0:32:43 52509
curl: (18) transfer closed with 31550105 bytes remaining to read
[root@DevServer tmp]# chmod +x /usr/local/bin/docker-compose
[root@DevServer tmp]# docker-compose version
Docker Compose version v2.27.0

验证:

docker-compose version

输出:

Docker Compose version v2.27.0

七、完整成功状态验证

docker -v
docker-compose version

示例:

Docker version 26.1.3
Docker Compose version v2.27.0

✅ Docker Engine ✅ Docker Compose ✅ 麒麟 V10 完美可用

八、 配置 Docker 国内镜像加速(必做)

之前 Docker 是能跑的,只是没法拉镜像

1️⃣ 创建 Docker 配置文件

mkdir -p /etc/docker
cat > /etc/docker/daemon.json << 'EOF'
{
  "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn",
    "https://mirror.ccs.tencentyun.com",
    "https://registry.docker-cn.com"
  ]
}
EOF

注意实际执行的命令是:
cat > /etc/docker/daemon.json << 'EOF'
{
  "registry-mirrors": [
    "https://docker.1panel.live"
  ]
}
EOF

2️⃣ 重新加载并重启 Docker

systemctl daemon-reexec
systemctl restart docker

3️⃣ 确认镜像加速生效

docker info | grep -A5 "Registry Mirrors"

你应该能看到:

Registry Mirrors:
 https://docker.mirrors.ustc.edu.cn/
 https://mirror.ccs.tencentyun.com/

4️⃣ 再次验证(关键)

 docker run --rm hello-world

5️⃣ 正确输出应包含:

Hello from Docker!
This message shows that your installation appears to be working correctly.

ssh实际执行日志:

[root@DevServer tmp]# docker -v
Docker version 26.1.3, build b72abbb
[root@DevServer tmp]# docker-compose version
Docker Compose version v2.27.0
[root@DevServer tmp]# mkdir -p /etc/docker
[root@DevServer tmp]# cat > /etc/docker/daemon.json << 'EOF'
> {
>   "registry-mirrors": [
>     "https://docker.1panel.live"
>   ]
> }
> EOF
[root@DevServer tmp]# systemctl daemon-reexec
[root@DevServer tmp]# systemctl restart docker
[root@DevServer tmp]# docker info | grep -A5 "Registry Mirrors"
WARNING: bridge-nf-call-iptables is disabled
 Registry Mirrors:
  https://docker.1panel.live/
 Live Restore Enabled: false

[root@DevServer tmp]# docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
17eec7bbc9d7: Pull complete
Digest: sha256:d4aaab6242e0cace87e2ec17a2ed3d779d18fbfd03042ea58f2995626396a274
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/