Singapore Flyer

Tuesday, February 20, 2018

Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Docker Error : Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

[root@sv23 ~]# docker build -t my-apache2 .
Sending build context to Docker daemon 64.16 MB
Step 1/1 : FROM httpd:2.4
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
[root@sv23 ~]# 


When I build a dockerfile, I am getting the above error.

How we can fix this?

1. Login to host.
2. mkdir -p /etc/systemd/system/docker.service.d
3. /etc/systemd/system/docker.service.d/http-proxy.conf
4. Add the following line
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:443/"
5. systemctl daemon-reload
6. systemctl restart docker
7. systemctl show --property=Environment docker

Try the build now, it will works!

[root@sv23 ~]#  docker build -t my-apache2 .
Sending build context to Docker daemon 64.16 MB
Step 1/1 : FROM httpd:2.4
2.4: Pulling from library/httpd
4176fe04cefe: Pull complete
d6c01cf91b98: Pull complete
b7066921647a: Pull complete
643378aaba88: Pull complete
3c51f6dc6a3b: Pull complete
4f25e420c4cc: Pull complete
ccdbe37da15c: Pull complete
Digest: sha256:6e61d60e4142ea44e8e69b22f1e739d89e1dc8a2764182d7eecc83a5bb31181e
Status: Downloaded newer image for httpd:2.4
 ---> 01154c38b473
Successfully built 01154c38b473
[root@sv23 ~]#


 

2 comments:

  1. Hello Shivin Vijay,

    I had the same problem as yours, and followed the steps. But i am getting the error below when trying to build the image.

    Step 1/32 : FROM centos
    Get https://registry-1.docker.io/v2/: http: error connecting to proxy https://proxy.example.com:443/: dial tcp: lookup proxy.example.com on 127.0.0.1:53: no such host

    Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).



    ReplyDelete
    Replies
    1. Hi Binyam,

      The given proxy "https://proxy.example.com:443" is a dummy one, you need to replace with your actual proxy if you have.

      Regards
      Shivin

      Delete