Akshay Hiremath
Akshay Hiremath

Reputation: 1105

Docker not able to pull images behind proxy TLS handshake timeout

I have latest Docker version 18.06.0 installed on CentOS 7. My server is in a corporate network so using a proxy server to access the registry. I have added proxy settings as per docker documentation. But finally adding proxy settings in worked partially. i.e. now docker is using proxy to pull the image before it runs.

But now it fails giving following error:

$ sudo 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: net/http: TLS handshake timeout.

Also, the login fails:

$ sudo docker login --username=XXXX
Password:
Error response from daemon: Get https://registry-1.docker.io/v2/: proxyconnect tcp: EOF

My proxy is pretty fast. When I’m using it to download anything from the internet using wget or curl I see 90 to 100Mbps speed. Other applications utils on my machine such as yum are using this proxy perfectly and it works well. Now I don’t know why only Docker has a problem in downloading the images.

The details of installation and configuration are as follow:

Version:

$ sudo docker version
Client:
Version: 18.06.0-ce
API version: 1.38
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:08:18 2018
OS/Arch: linux/amd64
Experimental: false

Server:

Engine:
Version: 18.06.0-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:10:42 2018
OS/Arch: linux/amd64
Experimental: false

OS Version:

Description: CentOS Linux release 7.2.1511 (Core)
Release: 7.2.1511

Docker proxy config:

$ cat /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment=“HTTP_PROXY=http://pqr.corp.xxx.com:8080”
Environment=“HTTPS_PROXY=https://pqr.corp.xxx.com:8080”
Environment=“NO_PROXY=localhost,127.0.0.1”

after adding this configuration I have already done

sudo systemctl daemon-reload
sudo systemctl restart docker

Looking for specific help.

I have gone through most of the posts on TLS Handshake Timeout issues but didn’t get any answer or suggestions working for me. My proxy is fine and docker is using it. I don’t understand why it gets that nasty timeout.

Upvotes: 19

Views: 83849

Answers (7)

Arani
Arani

Reputation: 1253

In my case, The problem was in the DNS settings. I set the appropriate DNS with the following command and it works now:

sudo resolvectl dns tun0 8.8.4.4 8.8.8.8

My OS: ubuntu 22.04
the tun0 is my internet interface.

Upvotes: 0

Terry Tú Nguyễn
Terry Tú Nguyễn

Reputation: 380

I encountered this with Docker Desktop on MacOS. It was resolved by adding

"debug": true

into configuration of Docker Engine (tab Setttings > Docker Engine) Good luck

Upvotes: 0

Demetry Pascal
Demetry Pascal

Reputation: 554

On Ubuntu 22-04 (WSL 2) I've just undo comment at export http_proxy field in file /etc/default/docker

Upvotes: 0

zslim
zslim

Reputation: 481

The answers before mine point towards this direction, but neither states it clearly: Removing all https proxy settings solves this problem. I had a https-proxy.conf file just like OP's and docker pull started to work after I deleted the HTTPS_PROXY line. I know that the https proxy I use works all right so it must be a problem on Docker's side.

I found this solution on serverfault.

Upvotes: 5

sg qy
sg qy

Reputation: 366

The config file is:

[Service]
Environment=“HTTP_PROXY=http://pqr.corp.xxx.com:8080”
Environment=“HTTPS_PROXY=https://pqr.corp.xxx.com:8080”
Environment=“NO_PROXY=localhost,127.0.0.1”

Notice that 3rd line: HTTPS_PROXY=https

Is the proxy server support HTTPS? Or there should be an error.

Maybe HTTPS_PROXY=http is correct.

By the way, a similar error is Get https://registry-1.docker.io/v2/: proxyconnect tcp: EOF

Upvotes: 21

Abhishek
Abhishek

Reputation: 173

I was also facing same issue behind firewall. Follow below steps:

$ sudo vim /etc/systemd/system/docker.service.d/http_proxy.conf
[Service]
Environment=“HTTP_PROXY=http://username:password@IP:port/”

Don’t use or remove https_prxoy.conf file.

reload and restart your docker

    $ sudo systemctl daemon-reload
    $ sudo systemctl restart docker
    $ docker pull hello-world
    Using default tag: latest
    latest: Pulling from library/hello-world
    1b930d010525: Pull complete
    Digest: sha256:2557*********************************8
Status: Downloaded newer image for hello-world:latest

Upvotes: 4

zhrist
zhrist

Reputation: 1558

Reason is usually related with your network settings. Especially, if your Docker is set up with Proxy, make it temporary with "No Proxy" option and it should work.

Cheers

Upvotes: 4

Related Questions