安装
更新包管理器:
sudo apt update
安装 Docker 的依赖包
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
添加阿里云 Docker 镜像源 GPG 密钥:
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
添加阿里云 Docker 镜像源:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/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
换源
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<EOF
{"registry-mirrors": ["https://docker.1ms.run","https://docker.xuanyuan.me",]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker