ubuntu16.04下安装docker

一、由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本

$ sudo apt-get remove docker docker-engine docker-ce docker.io

二、更新apt包索引(更新过程中速度很慢,可以看我的上篇博客)

$ sudo apt-get update

三、安装以下包以使apt可以通过HTTPS使用存储库(repository)

$ sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common

四、添加Docker官方的GPG密钥

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

五、使用下面的命令来设置stable存储库

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

六、再更新一下apt包索引

$ sudo apt-get update

七、安装最新版本的Docker CE

$ sudo apt-get install -y docker-ce

查看其它版本

$ apt-cache madison docker-ce

 选择要安装的特定版本,第二列是版本字符串,第三列是存储库名称,它指示包来自哪个存储库,以及扩展它的稳定性级别。要安装一个特定的版本,将版本字符串附加到包名中,并通过等号(=)分隔它们:

$ sudo apt-get install docker-ce=<VERSION>

八、验证docker

$ sudo docker run hello-world

 这样则安装成功

参考文献:https://blog.csdn.net/bingzhongdehuoyan/article/details/79411479

原文地址:https://www.cnblogs.com/liguix/p/12372010.html