删除旧版本
$ sudo apt-get remove docker docker-engine docker.io containerd runc
设置ubuntu docker仓库
//安装一鞋基础软件
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
//添加docker官方GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
//添加仓库
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
//安装docker
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
//添加用户到组
$ sudo usermod -aG docker $USER
//卸载
$ sudo apt-get purge docker-ce docker-ce-cli containerd.io
$ sudo rm -rf /var/lib/docker
添加阿里云镜像加速器
这个要用自己到账号开通容器镜像服务
$ sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://your-code.mirror.aliyuncs.com"]
}
EOF
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker