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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章