distribution: Registry - Upload purging environment overrides crash registry at startup

Attempting to change the values of the upload purging feature of the docker registry v2.4.0 via environment variables causes the registry to panic and exit on startup with the following message:

panic: uploadpurging config key must contain additional keys

The error is occurring on: CommitID: 4a915d6efdea23f437cb4144211aaf2faed27774 Line 129 File: registry/handlers/app.go purgeConfig, ok = v.(map[interface{}]interface{})

Setting any upload purging environment variable causes this error to occur such as: REGISTRY_STORAGE_MAINTENANCE_UPLOADPURGING_AGE: 111168h

When environment variables populate the “maintenance” map, the key type changes from “interface{}” to “string”, which I assume is why the map command is failing.

I added some variable dumping via “spew.Dump()” on those variables and the output is in the attached file called “variable_map_dump.log”

I’m not familiar enough with GO to know how to fix this. I’m hoping this is a trivial fix.

registry-uploadpurging-bug.zip

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 9
  • Comments: 22 (2 by maintainers)

Most upvoted comments

I also faced this issue but was able to find a way around it to make sure I can use environment variables to setup the storage.maintenance part of the configuration.

Using the following docker-compose.yml I was able to create a read-only proxy with upload purging deactivated by setting the REGISTRY_STORAGE_MAINTENANCE environment variable with raw YAML and it work perfectly.

version: '2'
services:
    image: registry:2.6.2
    environment:
      REGISTRY_AUTH: silly
      REGISTRY_HTTP_ADDR: :5000
      REGISTRY_HTTP_SECRET: my_little_secret
      REGISTRY_STORAGE: filesystem
      REGISTRY_STORAGE_MAINTENANCE: |-
        uploadpurging:
            enabled: false
        readonly:
            enabled: true
      REGISTRY_STORAGE_DELETE_ENABLED: 'false'
    volumes:
    - ./htpasswd:/run/secrets/htpasswd
    - ./data:/var/lib/registry
    ports:
    - 5000:500/tcp

Hope this can help you while this is getting fixed.

As I wasn’t using docker-compose but instead a bare Dockerfile, this worked for me:

docker run -d -p 443:5000 \
	--restart=always \
	-e REGISTRY_STORAGE_MAINTENANCE_READONLY="{\"enabled\":true}" \
	registry:2

The reason why I’m passing a JSON can be seen here: https://github.com/docker/distribution/blob/master/registry/handlers/app.go#L138-L142

@ejderdal For me both options still work with 2.7.1

-e REGISTRY_STORAGE_MAINTENANCE_READONLY="{\"enabled\":false}"
-e REGISTRY_STORAGE_MAINTENANCE="{\"readonly\":{ \"enabled\":true}}"

YAML instead of JSON also works.

hi, same here, REGISTRY_STORAGE_MAINTENANCE_UPLOADPURGING_AGE, cause an image panic. can someone from docker can comment?

=“{"readonly":{ "enabled":true}}”

-e REGISTRY_STORAGE_MAINTENANCE_READONLY={"enabled":false} worked for me.

I spoke too soon: time=“2016-06-18T01:14:23Z” level=warning msg=“Ignoring environment variable REGISTRY_STORAGE_MAINTENANCE_READONLY_ENABLED involving map with non-string keys”

I have a cron job that attempts to restart the registry read-only using this environment variable before invoking “registry garbage-collect”. Since the environment variable is ignored, I can’t use it. I’ll need to automate configuration file edits.

@RichardScothern I am getting the same error in registry logs. Ignoring environment variable REGISTRY_STORAGE_MAINTENANCE_READONLY_ENABLED involving map with non-string keys.

We have a mechanism where a request would come in - notify everyone that gc is about to run - restart registry in readonly mode - run gc - restart registry in RW mode. Wanted to change the read only value using environment variable, unfortunately which is not working. So right now, we are using 2 config files (replica of each other) one for RW and one for RO.