1. 卸载旧版
sudo apt-get remove docker docker-engine docker.io containerd runc
2. 安装依赖
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
3. 获取GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
4. 添加apt私有源
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
5. 安装Docker
sudo apt-get update
# 查看可安装版本
apt-cache madison docker-ce
sudo apt-get install docker-ce containerd.io
# 安装指定版本:docker-ce=<VERSION_STRING>
sudo apt-get install docker-ce=18.06.2~ce~3-0~debian
6. 测试
sudo docker -v
sudo docker run --rm hello-world
7. 移除
sudo apt-get autoremove --purge docker-ce
sudo apt-get autoremove --purge containerd.io