系统环境
ubuntu20.0.4
卸载旧版docker
sudo apt-get remove docker docker-engine docker.io containerd runc
设置docker资源库
1 更新资源库和必要软件
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
2 添加Docker的官方GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
3 设置稳定的存储库
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
安装docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
测试
sudo docker run hello-world