當虛擬機無法連接訪問到外網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)
通過設置代理可以解決:
-
創建http-proxy.conf文件:
$ mkdir -p /etc/systemd/system/docker.service.d $ vim /etc/systemd/system/docker.service.d/http-proxy.conf 添加如下內容: Environment="HTTP_PROXY=http://(host_name):(port_number)/" "HTTPS_PROXY=http://(host_name):(port_number)/"
如果設置格式如下會有 Get https://registry-1.docker.io/v2/: proxyconnect tcp: tls: first record does not look like a TLS 報錯
[Service]
Environment="HTTP_PROXY=http://<allowed_proxy_ipv4_address>:<proxy_port_num>/" [Service]
Environment="HTTPS_PROXY=https://<allowed_proxy_ipv4_address>:<proxy_port_num>/"
執行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
轉自
docker設置代理服務器,解決pull命令:Error response from daemon: Get https://registry-1.docker.io/v2 - SimpleWorker - 博客園
https://www.cnblogs.com/onetwothree/p/9371752.html
Error response from daemon: Get http s://registry-1.docker.io/v2/: proxyconnect tcp: tls: first record does not look like a TLS handshake - Stack Overflow
https://stackoverflow.com/questions/50392780/error-response-from-daemon-get-http-s-registry-1-docker-io-v2-proxyconnect/50409451