docker-issues
sk-126e337d8169448cba91e06175a5cc38
这个错误是因为银河麒麟桌面版(Kylin Desktop)的 codename(代码名)是 kylin,而不是标准的 Ubuntu codename(如 focal、jammy、noble 等)。Docker 官方源(download.docker.com)只为已知的 Ubuntu 版本提供 Release 文件,所以当 apt 尝试访问 https://download.docker.com/linux/ubuntu kylin Release 时,自然找不到文件,导致报错。
解决方案(推荐国内加速 + 兼容方式)
步骤1:先删除之前添加的无效源(避免反复报错)
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo apt update # 这步会清理掉旧的错误提示
步骤2:添加阿里云镜像源(最稳定、速度快,国内推荐)
阿里云的 Docker CE 源对 Ubuntu 系兼容性好,且支持大多数 codename 映射。
# 安装依赖(如果还没装)
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release apt-transport-https software-properties-common
# 添加 GPG 密钥(用阿里云的,兼容性更好)
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# 添加阿里云源(关键:手动指定一个相近的 Ubuntu codename)
# 银河麒麟桌面版常见基于 Ubuntu 18.04/20.04,用 focal(20.04)最稳
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 如果你的版本更接近 22.04,可改成 jammy 试试(见下面判断方法)
# echo "deb [arch=...] https://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy stable" | sudo tee ...
步骤3:更新并安装
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
如果 apt update 还是报类似 Release 文件不存在,可以换 codename 再试:
- focal(Ubuntu 20.04) → 最常见兼容银河麒麟桌面 V10
- bionic(18.04)
- jammy(22.04) → 如果是较新版银河麒麟桌面
怎么判断用哪个 codename?
运行下面命令看系统信息(贴出来我能帮你选最合适的):
lsb_release -a # 通常显示 Codename: kylin
cat /etc/os-release # 看 VERSION 或 UBUNTU_CODENAME 如果有
cat /etc/lsb-release # 有时有 DISTRIB_CODENAME=kylin
大多数银河麒麟桌面 V10 用 focal 就能正常安装 Docker。
步骤4:启动 + 测试
sudo systemctl enable --now docker
sudo usermod -aG docker $USER # 加组,免 sudo(需重新登录终端生效)
docker --version
docker run hello-world
如果阿里云源还是有问题(极少数情况)
用 Docker 官方源 + 手动指定 codename(同上,focal 或 jammy):
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
如果 apt update 成功但 install 时报依赖问题,可能是架构(arm64/x86_64)或旧版系统依赖缺失,贴错误我再细调。
把 cat /etc/os-release 或 lsb_release -a 的输出贴一下,我能给你最精确的源配置~