Docker Registry Cleaner¶
Smart Docker Registry cleaner.
Official repositories¶
GitHub: https://github.com/glorpen/docker-registry-cleaner
BitBucket: https://bitbucket.org/glorpen/docker-registry-cleaner
Docker Hub: https://hub.docker.com/r/glorpen/registry-cleaner
Contents¶
Docker Registry Cleaner¶
Smart Docker Registry cleaner.
Official repositories¶
GitHub: https://github.com/glorpen/docker-registry-cleaner
BitBucket: https://bitbucket.org/glorpen/docker-registry-cleaner
Docker Hub: https://hub.docker.com/r/glorpen/registry-cleaner
Features¶
- removing tags
- running garbage-collect
- cleaning empty repos (without tags)
- cleaning tags with regex and semantic versioning
- removing unknown tags
- no configuration changes in real registry service
State of Docker Registry¶
Workarounds for versions 2.6+ of Docker Registry.
See https://github.com/docker/distribution/issues/1811
Safe tag deletion¶
Docker Registry has no native support for deleting single tag from an image.
Fortunatelly it is possible to workaround this problem so Docker Registry Cleaner will safely remove tag from image, without removing image itself. The process is quite simple:
- find tags to remove
- upload fake image
- re-tag found tags to new image
- remove image with REST API call
Remove empty repositories¶
There is no way to remove repository using REST API, even one without tags - empty repo is still listed by registry.
Currently files should be cleaned on GC run on registry side (or some third party app, like this one).
Example configuration¶
Regex matching¶
Removes build tags created by CI:
patterns:
latest:
- "latest"
ci:
"r-([0-9]+)": "\\1"
"build-([0-9]+)": "\\1"
repositories:
some-name:
paths:
- "library/*"
cleaners:
latest:
type: pattern
pattern: ci
max_items: 10
Remove unknown tags¶
Removes tags that are not known for groups before it.
repositories:
some-name:
paths:
- "library/*":
cleaners:
# ... other groups ...
other:
type: max
max_items: 0
Semver tags¶
As in http://semver.org/
versioned:
type: semver
max_items: 100
groups:
current_minor:
where:
major: latest
minor: latest
preserve:
patch: 6
current_major:
where:
major: latest
minor:
min: 0
max: latest - 1
preserve:
patch: 1
archival:
where:
major:
max: latest - 1
preserve:
minor: 1
patch: 1
max_items: 20
Above config will:
- save only up to 100 newest versions
- save up to 6 versions with latest major & minor revisions
- save latest patch version for each minor release in latest major version (2.1.1, 2.2.10 but no 2.2.9)
- save latest minor & patch version for older major revisions
For more info see https://docker-registry-cleaner.readthedocs.io/en/latest/code/selectors.html#glorpen-docker-registry-cleaner-selectors-semver
Usage¶
App requires two paths:
- configuration file
- registry data, /var/lib/registry by default
It is advised to temporarly disable real registry (as when using normal registry garbage-collect
).
For example, to list repos:
docker run --rm -v `pwd`:/srv glorpen/registry-cleaner /srv/config.yml -d /srv/registry-data list-repos
and then to clean:
docker run --rm -v `pwd`:/srv glorpen/registry-cleaner /srv/config.yml -d /srv/registry-data clean
Api Documentation¶
glorpen.docker_registry_cleaner
¶
-
glorpen.docker_registry_cleaner.
__version__
¶ Current package version.
-
glorpen.docker_registry_cleaner.
__description__
¶ Short package description.
glorpen.docker_registry_cleaner.api
¶
glorpen.docker_registry_cleaner.app
¶
glorpen.docker_registry_cleaner.console
¶
glorpen.docker_registry_cleaner.native
¶
glorpen.docker_registry_cleaner.parser
¶
Selectors Documentation¶
glorpen.docker_registry_cleaner.selectors
¶
Each selector has two tasks:
- check if given tag is supported by it
- find tags for deletion from set of supported tags