dockerboot2dockerdocker-machine

Docker pull failed with request canceled while waiting for connection


I am trying to pull images to default docker machine. But I always get

docker@default:/etc$ docker run hellow-world
Unable to find image 'hellow-world:latest' locally
docker: 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).
See 'docker run --help'.
docker@default:/etc$

Even if i give --dns option same error

docker@default:/etc$ docker run hellow-world --dns=8.8.8.8
Unable to find image 'hellow-world:latest' locally
docker: 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).
See 'docker run --help'.
docker@default:/etc$

Tried adding DNS to config.json of the default machine

"EngineOptions": {
    "Dns": [
        "8.8.8.8",
        "8.8.4.4"
    ]
}

resolv.conf has following entry in default machine

docker@default:/etc$
docker@default:/etc$ cat /etc/resolv.conf
search <company name>
nameserver 10.0.2.3
docker@default:/etc$

This machine sits behind the proxy and I am using kitematic for creating default machine

Kitematic is started by a custom script which will set proxies and start kitematic

Recommended and All images are displayed at the start of kitematic. But can not pull any images

Creating new machine also gives warning

PS C:\Program Files\Docker Toolbox\kitematic> docker-machine create -d virtualbox --engine-opt dns=8.8.8.8 test
Running pre-create checks...
(test) Unable to get the latest Boot2Docker ISO release version:  Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 192.30.253.116:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Creating machine...
(test) Unable to get the latest Boot2Docker ISO release version:  Get https://api.github.com/repos/boot2docker/boot2docker/releases/latest: dial tcp 192.30.253.116:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Machine created with --dns option also has /etc/resolv.conf not as 8.8.8.8

docker@test:~$
docker@test:~$ cat /etc/resolv.conf
search <company name>
nameserver 10.0.2.3
docker@test:~$

PS:Issue solved after adding HTTP_PROXY to /var/lib/boot2docker/profile


Solution

  • Found solution

    Either add HTTP_PROXY to /var/lib/boot2docker/profile or

    create docker machine with --engine-env HTTP_PROXY=IP:PORT