Docker 的客户端和容器的运行时现在分开为不同的包里,要安装 Docker 需要同时安装这三个包:
sudo apt-get install docker-ce docker-ce-cli containerd.io
卸载旧版本
docker
、 docker.io
和 docker-engine
是旧版本的 Docker,如果之前安装过,则需要先卸载掉:
sudo apt-get remove docker docker-engine docker.io containerd runc
顺便一提,Docker 的镜像和容器是存储在 /var/lib/docker/
,如果不需要可以 rm -rf
删掉。
安装新版本
正式开始之前,先准备好依赖:
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
添加 Docker 的 GPG Key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
添加 Docker 官方源
x86_64 / amd64
echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
arm64
echo \ "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
armhf
echo \ "deb [arch=armhf signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
安装 Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io