docker設置代理服務器,解決pull命令:Error response from daemon: Get https://registry-1.docker.io/v2

當虛擬機沒法鏈接訪問到外網https://registry-1.docker.io/v2,執行docker pull命令會拋出異常,以下:

[root@localhost default]# docker pull debian
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)docker

經過設置代理能夠解決:

  • 建立http-proxy.conf文件:vim

    $ mkdir -p /etc/systemd/system/docker.service.d
    $ vim /etc/systemd/system/docker.service.d/http-proxy.conf
  添加以下內容:
    [Service]
    Environment="HTTP_PROXY=http://<allowed_proxy_ipv4_address>:<proxy_port_num>/"
    [Service]
    Environment="HTTPS_PROXY=https://<allowed_proxy_ipv4_address>:<proxy_port_num>/"3d

 

  • 執行reload命令:  $ sudo systemctl daemon-reload
  • 重啓docker:  $ sudo systemctl restart docker
  • 查看環境變量值: $ systemctl show --property=Environment docker

再次執行:

[root@localhost docker.service.d]# docker pull debian
Using default tag: latest
latest: Pulling from library/debian
55cbf04beb70: Pull complete
Digest: sha256:f1f61086ea01a72b30c7287adee8c929e569853de03b7c462a8ac75e0d0224c4
Status: Downloaded newer image for debian:latest代理

相關文章
相關標籤/搜索