Proxy settings do not work for either /etc/default/docker or systemd drop-ins

I am running docker
Client:
Version: 18.09.1
API version: 1.39
Go version: go1.10.6
Git commit: 4c52b90
Built: Wed Jan 9 19:35:31 2019
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.1
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 4c52b90
Built: Wed Jan 9 19:02:44 2019
OS/Arch: linux/amd64
Experimental: false

on

Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic

Neither the /etc/default/docker file using service docker start nor the service.d drop_in work for getting the daemon to use the proxy server. The only way I could get the docker daemon to use the proxy was to manually launch docker like so
https_proxy=http://domain\user:password@proxy.mycompany.com:80 dockerd

Any ideas???

Did you try this?

Direct link to the Docker proxy setup -> HTTP/HTTPS proxy

1 Like

Yep and those instructions are totally ignored by either the systemctl or docker itself. In fact, they are so ignored that the systemctcl command to show properties canā€™t even find the Environment property. Flat out just doesnā€™t work.

Hi. I just tried that example and it appears to be working for me. Iā€™m running on Docker CE 18.09.1

root@manager:~# mkdir -p /etc/systemd/system/docker.service.d
root@manager:~# echo -e "[Service]\nEnvironment=\"HTTP_PROXY=http://proxy.example.com:80/\"" > /etc/systemd/system/docker.service.d/https-proxy.conf
root@manager:~# sudo systemctl daemon-reload
root@manager:~# sudo systemctl restart docker
root@manager:~# systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/

Send me your output of lsb_release -a.

Hi.

root@manager:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.1 LTS
Release:	18.04
Codename:	bionic

Interesting. Donā€™t know why that doesnā€™t work on my Ubuntu VM. Same exact setup.

systemctl set-environment command does the trick though.

Great!
But Iā€™m confused too why it did not work for you when you placed it in the /etc/systemd/system/docker.service.d/https-proxy.conf fileā€¦

Me too, I have been using dropin files for more than 3 years and docker versions stretching back that far, and they have worked exactly as documented for all that time on RHEL.

Iā€™m not too worried about it at this point. I just wanted the registry container for a private registry and quite happy if no one can get to the docker.io from that box.

Hi I have the same issues mentioned and the exact same release ( as specified by usb_release -a ). I tried doing the systemctl set-environment . Can you mention the exact command used . I am able to set any variable but I wanted to set it for the service . (docker ).

Regards

This appears to still be an issue, but is specific to authenticated proxies only?
root@vprddock01:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic

The proxy settings show in the environment when itā€™s a straight-forward proxy server:port, but not when itā€™s a user:pass@server:port configuration if the username or password contains special characters that need to be url-encoded. As soon as the ā€˜%ā€™ sign is in the string, the This works fine in my Ubuntu 16.04 box but the same does not work in my 18.04 box:

Server:Port ::

root@vprddock01:~# cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:8080/"
root@vprddock01:~# systemctl daemon-reload
root@vprddock01:~# systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:8080/

Auth::

root@vprddock01:~# cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://user@pass:proxy.example.com:8080/"
root@vprddock01:~# systemctl daemon-reload
root@vprddock01:~# systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://user@pass:proxy.example.com:8080/

Complex Auth::

root@vprddock01:~# cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://user:complex%23pass@proxy.example.com:8080/"
root@vprddock01:~# systemctl daemon-reload
root@vprddock01:~# systemctl show --property=Environment docker
Environment=
root@vprddock01:~#

Does that help in any way?

2 Likes

This was actually the case for me! The escaped @ wrote as %40 was the reason for the empty Environment=
Many many thanks!

1 Like

Thanks, this works.
I copied the proxy string directly from bash export, didnā€™t work. It was:
http://username:p%40ssword@hostname:123
After changed to below, it works:
http://username:p@ssword@hostname:123
(Docker 18.09.7 on Ubuntu 18.04.3 LTS)

Hi
I experience the same issue.
As soon as I urlencode the password and ā€˜%ā€™ is used in the URL the Environment is not set => docker does not use proxy
But when I write the password without encoding the Environment is set but docker give me an error about malformed URL => still without proxy.
Is there any ticket at docker or ubuntu open about this?

i901:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic

Thanks!

1 Like

I spent nearly a week on this issue and finally found the answer. The issue is not with Docker but is with systemctl and how it reads the config files. Systemctl requires different escape characters than a URL does so a proxy var with special URL characters needs to have then escaped with the hex equivalent and the systemctl escapes.

So a backslash in domain\user becomes domain%5Cuser but this breaks systemctl because of the % sign.

What I found is that systemctl uses doubles to escape special characters like % and $

So what you need for systemctl with a url and special chars is domain%%5Cuser (Notice the DOUBLE %).

[Service]
Environment="HTTP_PROXY=http://domain%%5Cuser:complex%%23pass@proxy.example.com:8080/"
1 Like

i spent a week in this issueā€¦searching thru lot of posts ā€¦ no body has written anything about this problem with special charactersā€¦thanks a lot for your postā€¦it solved the problem when i was almost about to leave the installation.

I opened an issue to get the docs updated but they have not been changed yet.

I realize this is an old post but I assume people are still having the issue as I just did. You might want to try removing the quotes when adding the proxies to a .conf file. With the quotes I was not seeing any proxies defined when running:
[Service]
Environment=HTTP_PROXY=ā€œhttp://10.0.1.60:3128ā€
Environment=HTTPS_PROXY=ā€œhttp://10.0.1.60:3128ā€
Environment=NO_PROXY=ā€œlocalhost,127.0.0.1ā€
sudo systemctl show --property=Environment docker
Environment=

However, when I removed the ā€œā€ from the below config it worked
Donā€™t forget to run sudo systemctl daemon-reload

[Service]
Environment=HTTP_PROXY=http://10.0.1.60:3128
Environment=HTTPS_PROXY=http://10.0.1.60:3128
Environment=NO_PROXY=localhost,127.0.0.1

sudo systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://10.0.1.60:3128 HTTPS_PROXY=http://10.0.1.60:3128 NO_PROXY=localhost,127.0.0.1

Hope this helps!

1 Like