Adding HTTP/HTTPS proxy for docker image downloads

As part of development your lab network or corporate network might be under a proxy network to download docker images.
This article explains on how to add HTTP/HTTPS proxy to download the docker images in a corporate environment.

Add the below lines

[Service]
Environment=”HTTP_PROXY=http://proxy.mycompany.com:80/”

in /etc/systemd/system/docker.service.d/http-proxy.conf

and

[Service]
Environment=”HTTPS_PROXY=https://proxy.mycompany.com:443/”

in /etc/systemd/system/docker.service.d/https-proxy.conf

Replace proxy.mycompany.com with your companies proxy server details.

Additionally add nameserver entry also to resolve hostnames.

#Use your DNS server details.
nameserver 172.10.22.1

in /etc/resolv.conf

Once added restart docker daemon and reload. Commands below.

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

About the Author

Yogi

24 years of experience in various layers of software. Primarily experienced in system side software design and development on server management software. Interested in linux development in x86 and arm architecture.