Docker: 小白之路一(Ubuntu16.04安裝篇)

Docker的小白之路

一、Docker的安裝

1. ubuntu的安裝

卸載舊版本:

$ sudo apt-get remove docker docker-engine docker.io containerd runc

使用Docker倉庫進行安裝

設置倉庫

// 更新索引包
$ sudo apt-get remove docker docker-engine docker.io containerd runc

// 安裝apt依賴包,用於通過https來獲取倉庫
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

// 添加Docker的官方GPG祕鑰
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
// 會顯示OK

//9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 通過搜索指紋的後8個字符,驗證您現在是否擁有帶有指紋的密鑰。
$ sudo apt-key fingerprint 0EBFCD88

//使用一下指令設置穩定版倉庫(這行代碼可能會出錯,解決方法詳見問題二)
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu (lsb_release -cs) stable"

如果出現下面的問題:

問題一:

E: Malformed entry 64 in list file /etc/apt/sources.list (Component)
E: The list of sources could not be read.

需要檢查下你的倉庫是否添加準確/etc/apt/sources.list

問題二:

W: The repository 'https://download.docker.com/linux/ubuntu (lsb_release Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch https://download.docker.com/linux/ubuntu/dists/(lsb_release/-cs)/binary-amd64/Packages  404  Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.

把原來添加的倉庫刪掉,換成下面一個

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu  xenial  stable"

安裝Docker Engine-Community

// 更新下apt索引包
$ sudo apt-get update

// 安裝最新版本的Docker Engine-Community 和 containerd,或者轉到下一步安裝特定版本:
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

//要安裝特定版本的 Docker Engine-Community,請在倉庫中列出可用版本,然後選擇一種安裝。列出您的倉庫中可用的版本:
$ apt-cache madison docker-ce

// 有很多版本,LZ就不全部列出來了
docker-ce | 5:19.03.8~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 5:19.03.7~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 5:19.03.6~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 5:19.03.5~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 ...

// 使用第二列中的版本字符串安裝特定版本,例如 5:19.03.8~3-0~ubuntu-xenial
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

測試Docker是否安裝成功,輸入以下指令

$ sudo docker run hello-world

打印出以下信息則安裝成功:
在這裏插入圖片描述

參考地址:

  1. https://www.runoob.com/docker/ubuntu-docker-install.html
  2. https://stackoverflow.com/questions/41133455/docker-repository-does-not-have-a-release-file-on-running-apt-get-update-on-ubun
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章