Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Hub login behind a proxy

Tags:

docker

proxy

I recently installed Docker 18.04.0-ce on my Ubuntu 17.10 VM. While working behind a proxy I got stuck trying to log in into the Docker Hub registry. So when I run:

docker login -u <username> -p <cool password>

And I get this message:

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)

As far as my understanding goes from the research I did is that when you are behind a proxy and you want to use Docker you need to configure it accordingly even though having set your environment variable like so:

http_proxy=<my_proxy>
https_proxy=<my_proxy>
HTTP_PROXY=<my_proxy>
HTTPS_PROXY=<my_proxy>

Second, it looks like that Docker has multiple levels of proxy configurations meaning different configuration for build, containers, and the daemon.

I went and configured all of those to match my proxy, but I still get that message. YES, I DID RESTART the service and the daemon.

UPDATE:

$ docker info

Containers: 8
 Running: 0
 Paused: 0
 Stopped: 8
Images: 12
Server Version: 18.04.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.13.0-39-generic
Operating System: Ubuntu 17.10
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 7.79GiB
Name: docker-vb
ID: 447I:6DFI:JZ7V:F6SZ:BUCB:IFB2:4HGT:MXK2:Y5H5:EECC:FIQN:SZOH
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
HTTP Proxy: http://<proxy_ip>:<proxy_port>
HTTPS Proxy: http://<proxy_ip>:<proxy_port>
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
like image 597
KALALEX Avatar asked Jun 26 '26 04:06

KALALEX


1 Answers

The docker login typically needs to be run with sudo priviledges, so ensure that the HTTPS_PROXY environment is actually preserved. Simply done by

export HTTPS_PROXY=<your proxy>

Or simply pass it on the command line:

sudo HTTPS_PROXY=<your proxy> docker login -u <user> <registry>

The docker daemon doesn't need to be restarted. The above works fine (we use extensivelye proxies at work).

There may be some issues with your network reachability, proxy, and possibly the registry. The docker log can provide some clues:

Ubuntu: sudo journalctl -fu docker.service

RHEL: /var/log/messages | grep docker

like image 124
void4 Avatar answered Jun 28 '26 19:06

void4