Using systemd it’s rather simple to set specific environment variables for a specific application. In this example ill set a http(s) and noproxy settings for docker.
First we create systemd drop-in directory for the docker service:
sudo mkdir /etc/systemd/system/docker.service.d
Add file called /etc/systemd/system/docker.service.d/http-proxy.conf that includes the HTTP_PROXY environment variable:
[Service] Environment="HTTP_PROXY=http://proxy.internal:3128/" Environment="HTTPS_PROXY=http://proxy.internal:3128/" Environment="NO_PROXY=localhost,127.0.0.1/8"
Reload the daemon
$ sudo systemctl daemon-reload
Verify that the configuration has been loaded:
$ sudo systemctl cat docker.service
Restart Docker:
$ sudo systemctl restart docker