distribution: notification endpoints cannot be configured with environment variables

We are using the notification API to build an index of images pushed for building a search API. We have a configuration like -

notifications:
    endpoints:
        - name: pandora
          url: http://our-event-server.orgname.net/events
          timeout: 1s
          threshold: 10
          backoff: 1s
          disabled: false

Can we do something like REGISTRY_NOTIFICATIONS_ENDPOINTS_NAME_URL=<the_url_here> Since the endpoints is a list, I am not really sure what is the convention for defining environment variables are for this section.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 25 (4 by maintainers)

Most upvoted comments

FYI

docker run -dt --name "test_notification" \
-p 6500:5000 \
-v /mnt/registry-storage:/var/lib/registry \
-e REGISTRY_LOG_LEVEL=warn \
-e REGISTRY_STORAGE_DELETE_ENABLED=True \
-e REGISTRY_HTTP_SECRET=stubb-belle-seraglio \
-e REGISTRY_NOTIFICATIONS_ENDPOINTS="- name: alistener
  url: http://examples.com/notifications
  timeout: 500
  threshold: 5
  backoff: 1
  " \
registry:latest

I’ve just adapted the @sshipway solution to a docker-compose.yml file, and this works nicely:

version: '3.4'

services:
  registry:
    image: registry:2
    environment:
      REGISTRY_NOTIFICATIONS_ENDPOINTS: "- name: notifications-test\n  url: http://my-notification-server:8080\n  timeout: 5s\n  threshold: 8\n  backoff: 10s"
  

What about taking the REGISTRY_NOTIFICATIONS_ENDPOINTS_* variables like arrays/slices? confd is doing something similar with environment variables. Than you should be able to do something like this:

export REGISTRY_NOTIFICATIONS_ENDPOINTS_0_NAME=endpoint1
export REGISTRY_NOTIFICATIONS_ENDPOINTS_0_DISABLED=false
export REGISTRY_NOTIFICATIONS_ENDPOINTS_0_URL=http://localhost:8080/api/hook

export REGISTRY_NOTIFICATIONS_ENDPOINTS_1_NAME=endpoint2
export REGISTRY_NOTIFICATIONS_ENDPOINTS_1_DISABLED=false
export REGISTRY_NOTIFICATIONS_ENDPOINTS_1_URL=http://localhost:9000/api/hook

Since its yet not clear if things do work out and i found this issue searching for something else - it does work out setting it using the ENV variables

https://github.com/EugenMayer/docker-rancher-extra-catalogs/blob/master/templates/registry-slim/12/docker-compose.yml#L60

Or like in this concrete setup: https://github.com/EugenMayer/docker-image-portus/blob/master/test/docker-compose.yml#L68

I ran into this problem too.

I wanted to configure an Storage Middleware and only could do it with @lifeisfoo solution.

In spirit of trying to find a solution, I did write some Go Code (taken that I’m not a native go developer) and with my naive approach I could make what @tboerger suggested work.

export REGISTRY_NOTIFICATIONS_ENDPOINTS_0_NAME=endpoint1

However I don’t quite know how to contribute this, or if there’s a pending discussion or if it’s even good enough Go code 😂

Code is here

I just ran into this It’s a bit confusing, I think, in that you have a subset of the configuration options that are “special” and can’t be configured like everything else can when running using the pre-built container. I couldn’t find this documented anywhere and spent many hours trying to figure out why it wasn’t working.

Perhaps implementing support for EVs for configuring a single notification target is a suitable solution which will meet the needs of most people?

But for now, What do I use as the base for the configuration file? I want to ensure that I don’t inadvertently change something else by not using the correct starting point. Is it safe to create a new file and only specify the options I was previously using EVs for?