在Debian系统上获取Docker镜像主要有两种方式:直接从Docker Hub拉取和使用国内的镜像加速站点。以下是详细步骤:
更新包列表:
sudo apt update 安装必要的依赖包:
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release 添加Docker的官方GPG密钥:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 设置Docker稳定版仓库:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list 拉取Debian镜像:
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io 验证安装:
sudo docker run hello-world 获取可用镜像源:可以参考中提供的国内可用镜像源列表。
临时换源(每次拉取镜像时都需要指定相应的镜像源):
sudo docker pull 镜像源地址/镜像名 永久换源(推荐):
/etc/docker/daemon.json文件:sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": [ "镜像源1", "镜像源2" ] } EOF sudo systemctl daemon-reload && sudo systemctl restart docker 验证镜像源配置:
docker info | grep Registry Mirrors docker info 查看 Registry Mirrors 字段是否包含配置的镜像源。通过以上步骤,你应该能够在Debian系统上成功获取并安装Docker镜像。如果遇到问题,可以参考相关文档或社区支持。