一、更新包管理器:
sudo apt update
安装 Docker 依赖包:
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
添加 Docker GPG 密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
添加 Docker apt 仓库:
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
更新 apt 缓存:
sudo apt update
安装 Docker:
sudo apt install docker-ce docker-ce-cli containerd.io
启动 Docker 服务:
sudo systemctl start docker
确认 Docker 是否正确安装:
sudo docker run hello-world
##正确就会输出 “Hello from Docker!”。