https://github.com/devture/docker-registry-purger
A small tool used for purging a private Docker registry's old tags
https://github.com/devture/docker-registry-purger
docker docker-registry docker-registry-cleanup
Last synced: 11 days ago
JSON representation
A small tool used for purging a private Docker registry's old tags
- Host: GitHub
- URL: https://github.com/devture/docker-registry-purger
- Owner: devture
- License: mit
- Created: 2023-01-10T09:02:47.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-10T10:21:11.000Z (over 2 years ago)
- Last Synced: 2025-03-24T20:42:17.174Z (28 days ago)
- Topics: docker, docker-registry, docker-registry-cleanup
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Docker Registry Purger
[](https://hub.docker.com/r/devture/docker-registry-purger/)
This is a small tool used for purging a private Docker registry's old tags. It fetches the list of tags for an image, keeps `latest` and the most recent `NOF_TAGS_TO_KEEP` tags and deletes all other tags.
To actually reclaim the space, you'd need to also run the registry's [garbage collection](https://docs.docker.com/registry/garbage-collection/#run-garbage-collection).
## History
This is a fork of [blixhavn/docker-registry-retention](https://github.com/blixhavn/docker-registry-retention) which:
- adds `IMAGE_IGNORE_REGEX` / `DRY_RUN` support
- removes basic authentication support
- always keeps `latest` when deleting container image tags## Prerequisites
A Docker registry must be run with [`storage.deleted.enabled`](https://docs.docker.com/registry/configuration/#delete) (e.g. `REGISTRY_STORAGE_DELETE_ENABLED=true`) to allow deletion.
## Environment variables
Set the following environment variables and run the docker image, e.g as a cron job.
|**Variable** | **Description** | **Default value**|
|:--------------------|:-------------------------------------------------------------------|:-----------------|
|REGISTRY_URL |Base URL of the registry, with protocol (e.g. https://) | (undefined) |
|NOF_TAGS_TO_KEEP |Number of most recent tags to keep. `latest` is always kept. | 3 |
|IMAGE_IGNORE_REGEX |A regex for skipping processing of images (e.g. `postgres\|alpine`) | (undefined) |
|DRY_RUN |If set, performs a dry-run and does not delete anything | (undefined) |## Usage
1. `docker run -it --rm -e REGISTRY_URL=https://registry.example.com -e NOF_TAGS_TO_KEEP=3 devture/docker-registry-purger:latest`
2. Run the registry's [garbage collection](https://docs.docker.com/registry/garbage-collection/#run-garbage-collection) now to actually reclaim the space.