替代方案,改用国内的镜像站(网易镜像)
1.清除旧版本(可选操作)
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do apt-get remove $pkg; done
2.安装docker
apt-get update
首先安装依赖
apt-get install ca-certificates curl gnupg
信任 Docker 的 GPG 公钥并添加仓库:
install -m 0755 -d /etc/apt/keyrings
关键来了:
curl -fsSL https://mirrors.163.com/docker-ce/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \"(. /etc/os-release \&\& echo "VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
最后安装
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
3.安装docker-compose
apt install docker-compose