docker pull ubuntu:22.04 失败的解决记录

1. 重装 docker 套件

1.1 卸载清理原先的 docker 套件

bash 复制代码
sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
bash 复制代码
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
bash 复制代码
sudo rm /etc/apt/sources.list.d/docker.sources
sudo rm /etc/apt/keyrings/docker.asc

1.2. apt 安装 docker 套件

1.2.1. 配置 apt 源

存储为 hello_apt.sh

bash 复制代码
# Add Docker's official GPG key:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

执行:

sudo bash ./hello_apt.sh

1.2.2. 安装 docker 套件

bash 复制代码
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

2. 配置国内镜像加速器(最推荐)

这是在中国大陆环境下最稳定、最常用的解决方案。通过配置国内镜像源,Docker 会从国内的服务器拉取镜像,从而绕开网络问题-1-8

2.1. 编辑(或创建)Docker 配置文件

在终端中执行以下命令,这会使用 tee 命令创建或覆盖 /etc/docker/daemon.json 文件,并写入推荐的国内镜像源地址-6

bash 复制代码
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://docker.mirrors.ustc.edu.cn",
    "https://hub-mirror.c.163.com"
  ]
}
EOF

2.1. 重启 Docker 服务

复制代码
配置修改后,需要重启 Docker 才能使设置生效-1-8。bash
bash 复制代码
sudo systemctl daemon-reload
sudo systemctl restart docker

然后再执行 sudo docker pull ubuntu:22.04

相关推荐
虎头金猫1 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
分布式存储与RustFS1 天前
MinIO 官方 Docker 镜像被移除:依赖它的项目该怎么办
docker·云原生·devops·对象存储·minio·分布式存储
AI职业加油站1 天前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
此冬歌咏1 天前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
玉&心1 天前
通过Arthas在线诊断K8S中的内存及JVM等使用情况
docker·k8s·arthas
xing-xing1 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
-梅1 天前
linux(8) 软硬链接
linux·运维·服务器
赵文宇(温玉)1 天前
CoreDNS的hosts插件的缺行配置导致k8s集群异常
容器·kubernetes·rancher
guo_wen_qiang1 天前
上传本地镜像到harbor中
docker·容器·持续部署
张洛闻Eren1 天前
k8s云原生【第十课】:水平 Pod 自动扩缩容
运维·数据库·云原生·kubernetes·github