1.卸载旧版本:Docker 的旧版本被称为 docker,docker.io 或 docker-engine,如果已安装,请卸载它们:
sudo apt-get remove docker docker-engine docker.io containerd runc
2.安装 Docker Engine-Community:使用 Docker 仓库进行安装,在新主机上首次安装 Docker Engine-Community 之前,需要设置 Docker 仓库。之后,您可以从仓库安装和更新 Docker。
Raspbian 用户不能使用此方法!
对于 Raspbian,尚不支持使用仓库进行安装。您必须改为使用 shell 脚本方式。
设置仓库,更新 apt 包索引。
sudo apt-get update
3.安装 apt 依赖包,用于通过 HTTPS 来获取仓库。
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
4.添加 Docker 的官方 GPG 密钥:
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
5.通过搜索指纹的后8个字符,验证您现在是否拥有带有指纹的密钥。
sudo apt-key fingerprint 0EBFCD88
6.使用以下指令设置稳定版仓库:
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian \
$(lsb_release -cs) \
stable"
7.安装 Docker Engine-Community
更新 apt 包索引:安装最新版本的 Docker Engine-Community 和 containerd ,或者转到下一步安装特定版本:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io