Ubuntu22.04中仓库源registry.hub.docker.com使用docker pull/docker push超时timeout的解决方案 Linux

mowen 2024-06-26 135

1、docker pull/docker push超时,需要更改docker服务整体走proxyAddress,将以下proxyAddress更改为实际地址,即可解决docker pull超时的问题:

vim /etc/systemd/system/docker.service.d/http-proxy.conf
Environment="HTTP_PROXY=proxyAddress"
Environment="HTTPS_PROXY=proxyAddress"
Environment="NO_PROXY=localhost,127.0.0.1,*.xyz,*.cn"
systemctl daemon-reload && systemctl restart docker


有如下输出即为设置成功:

docker info|grep Proxy
HTTP Proxy: proxyAddress
HTTPS Proxy: proxyAddress
No Proxy: localhost,127.0.0.1,*.xyz,*.cn


优点:

无需更改daemon.json中的registry-mirrors镜像加速地址,仍然为registry.hub.docker.com;
直接docker pull/docker push时走docker服务的proxyAddress


2、官方registry:

34.226.69.105 registry.hub.docker.com
54.196.99.49 registry.hub.docker.com
3.219.239.5 registry.hub.docker.com
34.226.69.105 registry-1.docker.io
54.196.99.49 registry-1.docker.io
3.219.239.5 registry-1.docker.io


3、可选,设置容器内部使用proxy环境变量,适用于容器内部需要走proxyAddress的场景

vim ~/.docker/config.json
{
    "proxies": {
        "default": {
            "httpProxy": "proxyAddress",
            "httpsProxy": "proxyAddress"
        }
    }
}

与容器内部环境变量的映射关系:
httpProxy  ->  HTTP_PROXY
httpsProxy ->  HTTPS_PROXY


最新回复 (0)
返回
发新帖
X