90

I am getting the below error while building an image

Step 1/10 : FROM ubuntu:14.04
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Kuldeep Dangi
  • 4,126
  • 5
  • 33
  • 56

28 Answers28

65

I think the issue is that you are behind the proxy which in which case you need to write a manual configuration in Docker systemd service file. That will override the default docker.service file.

If you are using Docker for Windows, then simply set the default DNS to 8.8.8.8 on the "vEthernet (DockerNAT)" network adapter. But remember, this is not the best practice as you will be exposing from your office network.

In linux environment, you could add the environment variable as you are behind HTTP_PROXY or HTTPS_PROXY, as you are using port 80 or 443 respectively. As shown below in /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"

as for HTTTP_PROXY in /etc/systemd/system/docker.service.d/https-proxy.conf

[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:443/"

Then just restart docker after deamon reload:

 $ sudo systemctl daemon-reload
 $ sudo systemctl restart docker

Hope this works.

Reference: https://docs.docker.com/engine/admin/systemd/#httphttps-proxy

folaRin
  • 109
  • 8
mohan08p
  • 5,002
  • 1
  • 28
  • 36
  • 2
    No I am not behind any proxy. – Kuldeep Dangi Jan 03 '18 at 04:55
  • 4
    (Can you modify the question with your environment) Cool then try this.. sudo nano /etc/resolv.conf #add these lines on top and above one for home router… nameserver 8.8.8.8 nameserver 8.8.4.4 and then restart the docker. – mohan08p Jan 03 '18 at 06:14
  • I'm also adding lines defining proxies inside `Dockerfile` like this: `ENV http_proxy=http...`, `ENV https_proxy=...`, `ENV= ftp_proxy=...` – hurin May 28 '18 at 14:06
  • The HTTPS_PROXY value should start with "http://..." not "https://..." – KurioZ7 Oct 29 '19 at 06:33
  • 1
    If you are on windows and you are using a proxy, changing the proxy settings is way easier: Right click on Docker icon in the windows toolbar --> Settings --> Resources --> PROXIES – Adrian Nov 26 '20 at 12:15
  • 1
    I have an http proxy in my environment, and this configuration worked, Thanks. – Felipe Alvarez Mar 15 '21 at 01:15
  • on one of me nodes exist /etc/systemd/system/docker.service.d/http-proxy.conf – Nikolay Baranenko May 04 '23 at 10:43
55

I had the same problem and the following fix has worked for me: https://github.com/moby/moby/issues/22635#issuecomment-260063252

In my case I've added the following 2 nameserver lines to /etc/resolv.conf file.

before:

nameserver 127.0.0.53

after:

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.53
TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
mechatroner
  • 1,272
  • 1
  • 17
  • 25
51

I was facing the same issue when trying to build or pull an image with Docker on Win10. Changing the DNS of the Docker vEthernet(DockerNAT) network adapter to 8.8.8.8 fixed it for me, as described in this GitHub issue.

To change the DNS go to Docker (TrayIcon) -> Settings -> Resources -> Network and set a fixed DNS server ip = 8.8.8.8.

Changing the DNS server in the configuration of the windows network adapter worked too.

After restarting Docker is able to pull and build images again.

Version Info:

Windows 10 x64 Enterprise Version 1709

$ docker version
Client:
 Version:       17.12.0-ce
 API version:   1.35
 Go version:    go1.9.2
 Git commit:    c97c6d6
 Built: Wed Dec 27 20:05:22 2017
 OS/Arch:       windows/amd64

Server:
 Engine:
  Version:      17.12.0-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.2
  Git commit:   c97c6d6
  Built:        Wed Dec 27 20:12:29 2017
  OS/Arch:      linux/amd64
  Experimental: true
Ilya Palachev
  • 274
  • 1
  • 2
  • 16
bwibo
  • 671
  • 4
  • 11
47

On Mac OS X, I fixed this issue by not using the experimental virtualization framework.

Preferences -> Experimental Features

Mirek
  • 571
  • 4
  • 2
21

I got the same error and it was resolved by

docker logout registry-1.docker.io
FelixVo
  • 321
  • 2
  • 6
  • 2
    I installed docker while in VPN connection, figured out issue was related to vpn setting, but executing just this single line of command resolves the problem! – Gahan Nov 01 '21 at 18:39
8

I had the same issue and only found out after 30 minutes that I was on a VPN network for work which blocks other sites. I went off the VPN, and it worked :) This is definitely a network issue. When it said "not authenticated", I thought perhaps I needed some login credentials or so.

Sydney Molobela
  • 193
  • 3
  • 10
8

I face this problem when performing Ansible AWX installation.

I had my own private DNS :192.168.0.254 & 192.168.0.253 but was receiving same error.

Issue got resolved after change my DNS back to 8.8.8.8 & 8.8.4.4.

Bariou Alarou
  • 101
  • 1
  • 1
6

This error occurs on Big Sur 11.3.1, Intel when you check the box for "Use new virtualization framework" under the Experimental Features tab. Unchecking the box and restarting Docker fixed this problem for me.

groksrc
  • 2,910
  • 1
  • 29
  • 29
4

This may be the old one, but fixed available here

https://success.docker.com/article/i-get-x509-certificate-signed-by-unknown-authority-error-when-i-try-to-login-to-my-dtr-with-default-certificates

run following commands on each server

export DOMAIN_NAME=bootstrap.node1.local
export TCP_PORT=5000
openssl s_client -connect $DOMAIN_NAME:$TCP_PORT -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM | tee /etc/pki/ca-trust/source/anchors/$DOMAIN_NAME.crt
update-ca-trust
/bin/systemctl restart docker.service
David Lay
  • 2,956
  • 4
  • 27
  • 48
2

I have same issue with registry deployed in swarm. Restart docker helps but after some time it occurs again.

Redeploy registry with docker-compose

sudo docker-compose up -d

and all works fine

Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88
2

I also had problems with pull requests timing out. with both

docker pull hello-world
kubeadm config images pull

Perhaps this problem started for me when upgrading the VM from ubuntu 18 to 20, but there were also many kubernetes related config changes I made, so not sure.

anyway this solution resolved it for me.

https://stackoverflow.com/a/51648635/11416610

thanks @nils!

incase the above link brakes, here is a quote:

I had the same issue yesterday. Since I am behind a company proxy, I had to define the http-proxy for the docker daemon in:

/etc/systemd/system/docker.service.d/http-proxy.conf

The problem was, that I misconfigured the https_proxy, how it is described here. I used https:// in the https_proxy environment variable, which caused this error.

This configuration works for me:

cat /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment=http_proxy=http://IP:PORT/
Environment=no_proxy=localhost,127.0.0.1
Environment=https_proxy=http://IP:PORT/

Remember that you have to restart the docker daemon after changing this configuration. You can achieve this by using:

systemctl daemon-reload
systemctl restart docker
2

I was getting the same error. I am using a ubuntu 20.04 system

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)

I added the missing lines inside /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4
sudo nano /etc/resolv.conf

This is how it looks now.

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.53
options edns0 trust-ad
Nitin Raturi
  • 1,505
  • 1
  • 7
  • 12
  • 1
    Thank you! On same OS, tried a bunch of other proposed solutions but this was the one that worked for me. – Brian Z Oct 30 '22 at 18:23
1

I faced this issue on ubuntu when I am trying to build elasticsearch:

And I got this error:

ERROR: Get https://docker.elastic.co/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

It was my network connection problem. I was using VPN. so I disconnect my VPN connection and it's working fine.

for some reasons, it's trying to look up the domain it seems trying to search for the domain inside the local network after I disconnect the VPN everything worked fine.

Sayem
  • 104
  • 11
1

Windows 10 - home PC. none of the solution worked for me. what worked is un-install docker, restart PC, "run as administrator" while installing exe. worked!!

selva
  • 51
  • 1
  • 3
0

For my case, my company needed to define my IP in the White list in order to access the cloud.docker files. So do not hesitate to tell the responsible person if you have such error.

Yasi Klingler
  • 606
  • 6
  • 13
0

My issue was with Windows WSL, not only do you have to set the static dns servers as mentioned above in both the Docker Desktop client, and your containers, but you also need to add

 [network]
 generateResolvConf = false

to the /etc/wsl.conf in your linux containers. You will need to reboot your container as outlined in https://superuser.com/questions/1126721/rebooting-ubuntu-on-windows-without-rebooting-windows, or you can reboot your pc.

r2DoesInc
  • 3,759
  • 3
  • 29
  • 60
0

None of those solutions worked for me. I finally make it work simply by doing an update of docker. (MAC OS)

Romain TAILLANDIER
  • 1,765
  • 10
  • 18
0

I experienced this issue when trying to push to Docker.

  1. I updated Docker Desktop (via the GUI)

  2. I also ran docker system prune which prompts:

    WARNING! This will remove: - all stopped containers - all volumes not used by at least one container - all networks not used by at least one container - all dangling images

Confirm this by entering yes

Harry Riley
  • 165
  • 1
  • 6
0

It could be temporary network issue. I had same issue. I would these two

  • Re-run the command again
  • Restart the Docker Desktop
0

I had the same issue. I was getting this error while following the Udemy course. Since I was new to Docker I was actually building image by giving incorrect repository name( I was using Instructor username instead of mine docker repository username). When we push the image to Docker hub, use your docker repository name. Hence build image using your username.

docker build . -t docker_username/example:latest

where . represent current directory where your Dockerfile resides. Please first logged in your docker repository by using Docker desktop in your system

Hope this will solve someone's problem.

Akii
  • 1
  • 1
0

my solution was :

docker image prune and docker volume prune

reinaH
  • 534
  • 6
  • 10
0

Experienced this Error while I was trying to : docker pull odoo

and my solution was: sudo systemctl restart docker

shyakadev
  • 33
  • 5
0

Just log in through the terminal and use the below command

docker login

Enter username and password

Amit Kumar
  • 1,503
  • 14
  • 11
0

I was stuck too, tried everything I could then I tried these: https://fedingo.com/how-to-uninstall-docker-in-ubuntu/

Make sure you repeat step 1 and 2 mentioned in link untill step 1 shows nothing

then procceed with step 3 and the next steps

then delete docker folder from here

/etc/systemd/system/docker.service.d/

then follow :

https://docs.docker.com/engine/install/ubuntu/

Satnam
  • 1
-1

I have faced this error sometimes, my docker image is built smoothly before but when I have to remove all images ( even I do not make any change with the docker configuration files or any error in code). this still happens.

so I think that it may cause by the connection for it does a "Get https://registry-1.docker.io/v2/:....."

I have change DNS to google DNS 8.8.8.8 and 8.8.4.4 then it 's worked. good luck!

joe-khoa
  • 465
  • 1
  • 5
  • 10
-1

I got this error from my own Internet connection. Switched to another provider, all good.

ABCD
  • 7,914
  • 9
  • 54
  • 90
-1

Just add at the end of your shell command --dns 8.8.8.8

Max Chernopolsky
  • 617
  • 6
  • 17
-2

Check in case VPN is blocking..

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 07 '22 at 12:34
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31231082) – Juan Fontes Mar 12 '22 at 10:47