Docker behind a proxy

Working behind a proxy is always a bit of a pain. Luckly if you are doing so work with Docker behind a proxy you've come to the right place. Below steps should allow your docker instance to shot out to the internet to get images. Note, I will go about how to do this with systemd. You will need to adapt this slightly if using a different init system.


First make the following directory

mkdir /etc/systemd/system/docker.service.d

Then create a http-proxy.conf file under this directory. This conf file will hold the proxy details. The content as follows:


Take note, if you have a local docker registry that you don't want to go through the proxy you can set a no proxy option like so:


Essentially place the dns names or ips of the address you don't want to go through the proxy.

Once this is done simply flush your changes:

sudo systemctl daemon-reload

You can verify these changes have been applied via:

systemctl show --property Environment docker

Finally restart docker

systemctl restart docker

You should now be able to pull your images from your proxy.