开始安装
由于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
在生产系统上,可能会需要应该安装一个特定版本的Docker CE,而不是总是使用最新版本
apt-cache madison docker-ce
![image.png](https://img-blog.csdnimg.cn/img_convert/f32e12a7ddd8ad2f8e58ee05e2274a1e.png#align=left&display=inline&height=450&margin=[object Object]&name=image.png&originHeight=899&originWidth=1280&size=1036581&status=done&style=none&width=640)
选择要安装的特定版本,第二列是版本字符串,第三列是存储库名称,它指示包来自哪个存储库,以及扩展它的稳定性级别。要安装一个特定的版本,将版本字符串附加到包名中,并通过等号(=)分隔它们
sudo apt-get install docker-ce=<VERSION>
例如:sudo apt-get install docker-ce=5:19.03.11ubuntu-bionic
验证docker
查看docker服务是否启动
systemctl status docker
若未启动,则启动docker服务
sudo systemctl start docker
安装Docker-Componse
参考另一篇文章