Docker Community Forums

Share and learn in the Docker community.

Registry config of lists values using environment variables


(Janhelge) #1

Hello

My intention is to have most of configuration in environment variables and I am using the syntax described at github for docker distribution to override values in /etc/docker/registry/config.yml
In the documentation there is an example…

storage:
  filesystem:
    rootdirectory: /var/lib/registry

To override this value, set an environment variable like this:

REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY=/somewhere

This variable overrides the /var/lib/registry value to the /somewhere directory.

However I cannot get this syntax to work for config like …

notifications:
  endpoints:
    - name: alistener
      url: https://my.listener.com/event
      timeout: 1s
      ...

My question; Is it posible to override (or specify) a notification-endpoint using environment variables

I have tried a syntax on the docker run command like…

docker run -d  ... \
-e REGISTRY_NOTIFICATIONS_ENDPOINTS_NAME="- portus" \
-e REGISTRY_NOTIFICATIONS_ENDPOINTS_URL="http://portus.domain.com:3000/v2/webhooks/events" \
-e REGISTRY_NOTIFICATIONS_ENDPOINTS_TIMEOUT="500ms" \
...  registry

…but these environment settings does not override the endpoint configuration as I intend to. It is not working.

I realize that the notifications_endpoints config info is supposed to be an YML-array-list, and maybe I have to use a different syntax for this reason.

My question is: How could I specify such list config using environment variables?

Best regards Jan Helge


(Janhelge) #2

At last I found a solution. It is possible to use yml as a value. So following syntax will do the trick…

 ...
 -e REGISTRY_NOTIFICATIONS_ENDPOINTS="- name: portus
  url: https://portus.domain.com:3000/v2/webhooks/events
  timeout: 500ms
  threshold: 5
  backoff: 1s" \
 ...

NOTE: You have to pay special attention to spaces to keep the yml is correctly formatted