CentOS7下docker安装,代理设置,链接超时错误解决

1. 拉取测试hello-world镜像

# 执行命令
docker run hello-world

# 报错如下,网络超时,如果您位于中国或其他网络受限的地区,可能无法直接访问Docker Hub
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Retrying in 1 second 
docker: error pulling image configuration: download failed after attempts=6: dial tcp 104.18.123.25:443: i/o timeout.
See 'docker run --help'.

2. 设置docker网络代理

在路径 /etc/systemd/system/ 中创建文件夹 docker.service.d ,并创建一个 http-proxy.conf 文件。写入以下内容(IP和端口换成自己的代理):

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

注意,这个的HTTPS_PROXY也要设置为和HTTP_PROXY一样,否则会出现另外一种错误。

3. 重启docker

更新配置。

systemctl daemon-reload

重启docker。

systemctl restart docker

查看代理配置。

systemctl show --property=Environment docker

再次进行测试。

docker run hello-world

猜你喜欢

转载自blog.csdn.net/qq_39997939/article/details/131256142
今日推荐