上来先清理一下旧版本

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

然后更新一下

sudo apt-get update -y

然后让apt支持https的源

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

加一个docker的GPG Key

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

然后加一个docker的官方源

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

再更新一下

sudo apt-get update -y

最后是安装docker

sudo apt-get install -y docker-ce docker-ce-cli containerd.io

统一起来就是这样

sudo apt-get remove -y docker docker-engine docker.io containerd runc
sudo apt-get update -y
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

转自喵星人聚居地


使用官方安装脚本自动安装
安装命令如下:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

也可以使用国内 daocloud 一键安装命令:

curl -sSL https://get.daocloud.io/docker | sh