I am new to docker and Ubuntu 16.04 OS as well. My configuration is as follows :


$lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description:    Ubuntu 16.04.5 LTS

Release:    16.04

Codename:   xenial

Docker :

$ docker info

Containers: 2

 Running: 0

 Paused: 0

 Stopped: 2

Images: 5

Server Version: 18.09.0

Storage Driver: overlay2

 Backing Filesystem: extfs

 Supports d_type: true

 Native Overlay Diff: true

Logging Driver: json-file

Cgroup Driver: cgroupfs


 Volume: local

 Network: bridge host macvlan null overlay

 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk 

Swarm: inactive

Runtimes: runc

Default Runtime: runc

Init Binary: docker-init

containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39

runc version: 4fc53a81fb7c994640722ac585fa9ca548971871

init version: fec3683

Security Options:



  Profile: default

Kernel Version: 4.15.0-42-generic

Operating System: Ubuntu 16.04.5 LTS

OSType: linux

Architecture: x86_64

CPUs: 4

Total Memory: 15.4GiB

Name: smarthi-ORADEV


Docker Root Dir: /var/lib/docker

Debug Mode (client): false

Debug Mode (server): false

Username: bluesangig

Registry: https://index.docker.io/v1/


Experimental: false

Insecure Registries:

Live Restore Enabled: false

Product License: Community Engine

WARNING: No swap limit support

I am connect to office VPN network and all my accesses to office and internet are working fine with my Network proxy configuration done in my laptop.

Even docker container run commands are also working fine.

But when I try to do docker image build using a docker file whose content is:

FROM busybox RUN echo "building simple docker image" CMD [echo, "hello container"]

I am getting below error message:

$ docker image build -t testimg .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM busybox
Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

I had searched a bit and found that we may need to set the proxy in the ~/.docker/config.json file, and I had added the proxy entries as mentioned in the issue

Even after adding the entries as suggested in the above issue, I still face the same issue.

I am little clueless now on how to solve this issue with docker image build. Any help would be greatly appreciated.


After a much trail and error and lot of googling... finally I was able to make docker work behind my office VPN.

And for the benefit of people who might be facing issue similar to mine, below are the steps I performed to resolve the issue:

Three different places where I had modified the proxy value and that got the issue fixed.

  1. /etc/systemd/system/docker.service.d/http-proxy.conf Check if this file exists in your setup, and if it does not create this file and perform below steps:

    • Open the file and add below statements in it and save:

    • Flush the above changes by running below command:

      sudo systemctl daemon-reload
    • Verify that the above changes have been taken affect by running the command below. This should print the Environment variable value:

      sudo system ctl show --property Environment docker
    • Once you successfully verify that the variable is set, restart the docker service by running below command:

      sudo systemctl restart docker
  2. ~/.docker/config.json: Add the json property shown below to the existing properties in the file.

        "proxies": {
          "defaults": {
  3. /etc/default/docker : Open or create this file with this content:

    export http_proxy='http://proxyHost:proxyPort'
    export https_proxy='http://proxyHost:proxyPort'

Once I had all the above changes done, I rebooted my setup and then docker image pull and other docker commands started working without issues.

Note: All the above changes may not be required but for me above changes made sure that docker works after I connect to my VPN.

| improve this answer | |
  • On Linux I had to use lower case names for the proxy to work. So in /etc/systemd/system/docker.service.d/http-proxy.conf I had to use "Environment=http_proxy=http...", with lower case and no quotes. – java4africa Oct 30 '19 at 10:40

In the file /etc/default/docker, add:

export http_proxy='http://<host>:<port>'
export https_proxy='http://<host>:<port>'

Restart Docker

sudo service docker restart
| improve this answer | |
  • thank you for the reply, but I donot see /etc/default/docker file in my system. I see this issue everytime I reboot my machine. And one of my friends has suggested to to add "Acquire::http::proxy "<proxyHost>:<proxyPort>/"; in /etc/apt/apt.conf file... If I do that I see that things started working. But today even that solution is not working... Any suggestions on how to make the network stable on my system? Please help – Santosh Giri Govind Marthi Dec 8 '18 at 4:39
  • I had even tried adding the above file with the export statmements in it: $ cat /etc/default/docker export http_proxy='www-proxy.us.oracle.com:80' export https_proxy='www-proxy.us.oracle.com:80' Still I see the same issue occurring: $ docker container run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get registry-1.docker.io/v2: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers). See 'docker run --help'. Any further help with this regards? – Santosh Giri Govind Marthi Dec 9 '18 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.