AppNeta CMP (C50) - Docker Daemon Proxy for systemd
search cancel

AppNeta CMP (C50) - Docker Daemon Proxy for systemd

book

Article ID: 268621

calendar_today

Updated On:

Products

AppNeta

Issue/Introduction

In some environments a Proxy is required for outbound connectivity.  Docker Daemon for systemd can be configured with a proxy to ensure that all commands and other communications go through the configured proxy.

For example, you may see the following error trying to setup a CMP:

sudo /bin/bash setup.sh  
> Would you like to use host networking? (y/n) (default=n): y
Selected Host networking
Setting container time zone to America/New_York
Setting talos port to 26268
Error response from daemon: Get "https://appneta.azurecr.io/v2/": context deadline exceeded
Exited with code 1. Error on line 1.

 

Resolution

The above error was a result of the script timing out due to it being unable to reach AppNeta's Azure Repository for CMPs as Docker required a Proxy to be configured.

 

You can configure a proxy for the Docker Daemon for Systemd with the following steps:

1. We will want to check or create if the drop-in driectory for Docker Daemon exists for Systemd:

admin@test:~$ sudo ls -ld /etc/systemd/system/docker.service.d
[sudo] password for admin:
ls: cannot access '/etc/systemd/system/docker.service.d': No such file or directory

If the above example the directory does not exist so we will need to create it:

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

 

2. Now that the directory has been created we will want to create a configuration file to supply the Proxy settings:

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

3. We can now populate the Proxy configuration with the following content, please note that the formatting is important and the first line must be [Service]

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="HTTPS_PROXY=http://proxy.example.com:80/"

If you have internal Docker registries or FQDNs/IPs that do not need to connect through a proxy, add the NO_PROXY variable:

Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.example.com"

 

4. Apply the changes to the Docker Daemon:

sudo systemctl daemon-reload

 

 

5. We can verify that the Proxy configuration has been successfully loaded:

sudo systemctl show --property Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/
Environment=HTTPS_PROXY=http://proxy.example.com:80/

 

 

6. Once they have been verified and they appear correctly configured you can restart Docker to apply them:

sudo systemctl restart docker

Additional Information

Docker's official documentation for configuring a Docker Daemon Proxy can be found here: Configure the daemon with systemd | Docker Documentation