Using docker behind a http-proxy on Fedora 20 with systemd starting the docker-service

On my Fedora 20 System docker is started by systemd.

The problem during installing an image is, that I'm living behind a proxy.

In the systemd configuration file you can set a file to load the environment from.

In my case this is /usr/lib/systemd/system/docker.service

Under the section [Service] add the entry for Environmentfile:


[Service]                                                                      
EnvironmentFile=/etc/sysconfig/docker
ExecStart=/usr/bin/docker -d
Restart=on-failure
 
In /etc/sysconfig/docker, the proxy variables are set:

HTTP_PROXY=http://<IP>:<Port>                                         
http_proxy=$HTTP_PROXY
HTTPS_PROXY=$HTTP_PROXY
https_proxy=$HTTP_PROXY

export HTTP_PROXY HTTPS_PROXY http_proxy https_proxy

After a refresh of the new config with

sudo systemctl daemon-reload

and restart

sudo systemctl restart docker.service

I can install an image:

sudo docker build -rm -t ewer/MySQL .
[sudo] password for ewer:
Uploading context 55.81 kB
Uploading context
Step 0 : FROM fedora:20
Pulling repository fedora
58394af37342: Download complete
511136ea3c5a: Download complete
8abc22fbb042: Download complete
 ---> 58394af37342