Ubuntu 19.04 Docker 源配置与报错现象
参考各类技术博客及常规操作习惯,通常采用以下命令来添加 Docker 的软件源:
root@ubuntu:~# sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
但在实际操作中,执行上述命令却引发了诸多问题,甚至让人对自身的 Linux 运维能力产生怀疑。执行该命令后,终端提示了如下错误信息:
Ign:1 https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu eoan InRelease
Err:2 https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu eoan Release
404 Not Found [IP: 218.104.71.170 443]
Hit:3 http://cn.archive.ubuntu.com/ubuntu eoan InRelease
Hit:4 http://cn.archive.ubuntu.com/ubuntu eoan-updates InRelease
Hit:5 http://cn.archive.ubuntu.com/ubuntu eoan-backports InRelease
Hit:6 http://cn.archive.ubuntu.com/ubuntu eoan-security InRelease
Reading package lists... Done
E: The repository 'https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu eoan Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
检查系统中的 apt 源配置文件,内容如下所示:
deb [arch=amd64] https://download.docker.com/linux/ubuntu eoan stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu eoan stable
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
从配置文件本身来看,语法并无明显错误。然而,在执行 apt 更新操作时,依然会遭遇各种报错,最终无法找到 docker-ce 安装包,导致安装过程失败:
root@uduntu:~# apt-get update
Get:1 http://cn.archive.ubuntu.com/ubuntu eoan InRelease [255 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu eoan-updates InRelease [88.4 kB]
Hit:3 http://cn.archive.ubuntu.com/ubuntu eoan-backports InRelease
Get:4 http://cn.archive.ubuntu.com/ubuntu eoan-security InRelease [92.9 kB]
Ign:5 https://download.docker.com/linux/ubuntu eoan InRelease
Err:6 https://download.docker.com/linux/ubuntu eoan Release
404 Not Found [IP: 13.225.103.32 443]
Reading package lists... Done
E: The repository 'https://download.docker.com/linux/ubuntu eoan Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
root@uduntu:~# apt search docker-ce
root@uduntu:~#
面对此类棘手问题,网络上流传的多种解决方案往往无效。有观点将其归结为网络问题导致无法连接外网源码库,但尝试切换网易、阿里以及中科大等国内镜像源后,问题依旧存在。实际上,解决思路并不复杂:对比分析阿里、科大和网易等镜像源的配置文件写法,参照其格式进行配置即可顺利解决。
具体解决步骤如下:
在 sources.list 文件中追加或修改为以下内容:
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
随后执行 apt 源更新命令:
root@uduntu:~# apt-get update
Get:1 http://cn.archive.ubuntu.com/ubuntu eoan InRelease [255 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu eoan-updates InRelease [88.4 kB]
Hit:3 http://cn.archive.ubuntu.com/ubuntu eoan-backports InRelease
Get:4 http://cn.archive.ubuntu.com/ubuntu eoan-security InRelease [92.9 kB]
Get:5 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:6 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [9,594 B] Fetched 511 kB in 11s (48.3 kB/s)
Reading package lists... Done
root@uduntu:~#
此时报错消失,再次检查是否可获取 docker-ce 安装包:
root@uduntu:~# apt search docker-ce
Sorting... Done
Full Text Search... Done
docker-ce/bionic,now 5:19.03.4~3-0~ubuntu-bionic amd64 [installed]
Docker: the open-source application container engine
docker-ce-cli/bionic,now 5:19.03.4~3-0~ubuntu-bionic amd64 [installed,automatic]
Docker CLI: the open-source application container engine
root@uduntu:~
总结
以上所述是小编给大家介绍的分享Ubuntu19无法安装docker源问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对本站网站的支持! 如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!