更新现有的软件包列表
sudo apt update
下载必要软件
sudo apt install apt-transport-https ca-certificates curl software-properties-common
将官方 Docker 版本库的 GPG 密钥添加到系统中
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Docker版本库添加到APT源
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
更新软件包
sudo apt update
确保要从 Docker 版本库,而不是默认的 Ubuntu 版本库进行安装
apt-cache policy docker-ce
安装 Docker
sudo apt install docker-ce
检查 Docker 是否正在运行
sudo systemctl status docker