个人技术空间关于本站

docker pull超时解决

最近发现使用docker pull下载镜像的时候会显示超时。

root@blog:~# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
9c704ecd0c69: Retrying in 1 second
error pulling image configuration: download failed after attempts=6: dial tcp 108.160.170.44:443: connect: connection refused

懒得搭建私有仓库,所以配置一下代理简单解决一下。

首先要有一个http代理

这里选一个你自己常用的代理工具,自行搭建

配置 Docker 使用代理

1.为 Docker 守护进程配置代理

创建或编辑 Docker 守护进程配置文件 /etc/systemd/system/docker.service.d/http-proxy.conf:

[Service]
Environment="HTTP_PROXY=http://127.0.0.1:8081/"
Environment="HTTPS_PROXY=https://127.0.0.1:8081/"
Environment="NO_PROXY=localhost,127.0.0.1"

将127.0.0.1:8081修改为你自己的http代理地址

2.重新加载并重启 Docker 服务
sudo systemctl daemon-reload
sudo systemctl restart docker
3. 验证代理配置

可以通过拉取一个 Docker 镜像来验证代理配置是否生效:

root@blog:~# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
9c704ecd0c69: Pull complete
Digest: sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest

需要注意的时候,配置了代理后,所有镜像都会通过代理拉取,如果你有内部私有镜像仓库的话可能会出现失败的问题。

CreateBy:2024-06-18,UpdateBy:2024-06-18

评论

还没有评论,欢迎第一个留言。
← 请输入您的姓名
← 请输入常用邮箱(不会公开)
← 请输入个人网站(可选)
← 请输入评论内容,文明交流
← 请先完成人机验证