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.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 9
- Comments: 22 (2 by maintainers)
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.maintenancepart of the configuration.Using the following
docker-compose.ymlI was able to create a read-only proxy with upload purging deactivated by setting theREGISTRY_STORAGE_MAINTENANCEenvironment variable with raw YAML and it work perfectly.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:
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.1YAML instead of JSON also works.
hi, same here, REGISTRY_STORAGE_MAINTENANCE_UPLOADPURGING_AGE, cause an image panic. can someone from docker can comment?
-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.