Using Docker Behind a Proxy

Justin 09 Dec , 2015 0 comments Docker

I have started learning about containerisation with the view ultimately of deploying it in a production environment for some of the services at my larger clients. Testing and developing this however is made more difficult by the use of a mandated proxy by those who control the WAN and access to the greater internet.

Consequently when I was attempting to pull images and files from the Docker Hub I was getting errors.

Now I could use environment variables, but as this is a test machine and is on my laptop it is not always going to be behind a proxy (it is most of the time, just not always).

Consequently I wanted to add or enable the proxy variable in the Docker configuration file. Fortunately it is easy to find both the file and the line to edit.

For my test machine which is running Ubuntu Server 14.04 it is in the following location


So you want to edit it (remembering to use sudo) with the following command

sudo nano /etc/default/docker

in this file there is a commented out line beginning with

#export http_proxy ““

Simply remove the # from the start of the line, and fill in the section that contains with your proxy details (http://serveraddress:portnumber/)

Save the file [Ctrl+o] Alternatively you can save the file upon exit, the system will prompt you

If it refuses to save to the location, it is most likely due to lack of permissions, you did sudo when you opened nano didn’t you?

Exit Nano [Ctrl+x]

Now restart the docker process

sudo service restart (again notice the sudo)

Now you can pull down images if you got your setting right


Written By Justin

Leave a Reply

You have to agree to the comment policy.

2 × two =

This site uses Akismet to reduce spam. Learn how your comment data is processed.