Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker for windows: "server misbehaving" when trying to pull

Tags:

docker

I'm trying to run docker on windows (OS: Microsoft Windows 10 Pro 64bit, Docker ver: 18.09.0, build 4d60db4), by following the hello-world instruction here. Then I got this following "server misbehaving" error:

Error response from daemon: Get https://registry-1.docker.io/v2/: proxyconnect tcp: dial tcp: lookup <companyProxy> on 192.168.65.1:53: server misbehaving.

I tried to change the DNS (in Docker setting - Network - DNS Server) from Automatic to Fixed (8.8.8.8 or 8.8.4.4) as suggested here, but still did not solve the problem, and resulted in another type of error ("timeout exceeded").

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 am behind company's proxy, and have set the proxy (and the credentials) both on environment variable and also docker setting. I also tried to reinstall both docker and hyperV but still got the same problem.

Can anybody help? Thanks

like image 872
Leonard AB Avatar asked Nov 26 '18 05:11

Leonard AB


1 Answers

We had this problem on Linux behind a corporate proxy after upgrading Docker from version 17 to the latest 19 (currently 19.03.5).

# docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: proxyconnect tcp: dial tcp: lookup http on 1.2.3.4:53: server misbehaving.

1.2.3.4 is the IP of our DNS server, which itself worked fine - I could resolve different hosts, also registry-1.docker.io from Docker.

Solution

The problem was how we set the proxy globally in /etc/systemd/system/docker.service.d/http-proxy.conf. Since its an MS AD user, it contains the username in the format of domain\user like this:

[Service]
Environment="HTTP_PROXY=http://domain\user:[email protected]:80"

Same thing for HTTPS_PROXY. While this worked on version 17, it doesn't seem to work with 19. Now the backslash seems to cause problems. Just remove it like this:

[Service]
Environment="HTTP_PROXY=http://user:[email protected]:80"

How to check if this is a problem

I'm not sure if this changed with version 19 or already in version 18, since we skipped 18. But if you upgrade to 18 or 19 this is a thing i'd check. There is a simply way to figure it out:

 docker info | grep -i proxy

If you see censored credentials like this

HTTP Proxy: http://xxxxx:[email protected]:80
HTTPS Proxy: http://xxxxx:[email protected]:80

then you're not affected of this issue. But if you see the plain credentials, Docker can't parse them because of the backslash or maybe other special characters included in your env variable.

like image 98
Lion Avatar answered Sep 20 '22 02:09

Lion