1、删除旧版本
sudo apt-get remove docker docker-engine docker.io containerd runc
2、更新ubuntu数据源列表
sudo apt-get update
3、安装 https 请求库
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
4、添加Docker的官方GPG密钥
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
5、使用以下命令设置存储库
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
6、安装docker 引擎
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
7、测试安装docker 是否成功
sudo docker run hello-world
8、查看docker版本
docker version