記一次Ubuntu19無法安裝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
//然后下載安裝相關密鑰
curl -fsSL http://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

 

更新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:~# 

 

OK這就搞定了!

好啦這次就到這里了,我繼續更新我的大腦啦!!!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM