Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/n0madic/gitlab-registry-images-cleaner
Utility to remove old Docker images from the Gitlab registry
https://github.com/n0madic/gitlab-registry-images-cleaner
Last synced: 10 days ago
JSON representation
Utility to remove old Docker images from the Gitlab registry
- Host: GitHub
- URL: https://github.com/n0madic/gitlab-registry-images-cleaner
- Owner: n0madic
- License: gpl-3.0
- Created: 2018-02-05T08:29:49.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-13T09:55:00.000Z (over 3 years ago)
- Last Synced: 2024-09-04T00:05:02.193Z (3 months ago)
- Language: Python
- Size: 54.7 KB
- Stars: 55
- Watchers: 5
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gitlab registry images cleaner
## Introduction
*gitlab-registry-images-cleaner* is a tool for deleting Docker images in Gitlab Docker registry.
Tested on Python 3 and Gitlab 11.10.## Usage
### Command Line Interface
```
usage: gricleaner.py [-h] [-i FILE] [-j URL] [-u NAME] [-p SECRET] [-g URL]
[-r namespace/project] [-t SNAPSHOT] [-mr] [-mn] [-m X]
[-d X] [--clean-latest] [--clean-all] [--single-tag]
[--dry-run] [-z] [-v] [--debug]Utility to remove Docker images from the Gitlab registry
optional arguments:
-h, --help show this help message and exit
-i FILE, --ini FILE use this INI file (default: gricleaner.ini)
-j URL, --jwt URL Gitlab JWT authentication url. Or use $GITLAB_JWT_URL. (overrides INI value)
-u NAME, --user NAME Gitlab admin username. Or use $GITLAB_USER. (overrides INI value)
-p SECRET, --password SECRET
Gitlab admin password. NOT SAFE! Or use $GITLAB_PASSWORD. (overrides INI value)
-g URL, --registry URL
Gitlab docker registry url. Or use $GITLAB_REGISTRY. (overrides INI value)
-r namespace/project, --repository namespace/project
scan only these repositories (one or more)
-t SNAPSHOT, --tag-match SNAPSHOT
only consider tags containing the string or regex (with --match-regex flag)
-mr, --match-regex match tags by regex
-mn, --match-negate negate matched tags (tag should NOT match)
-m X, --minimum X minimum allowed number of images in repository (overrides INI value)
-d X, --days X delete images older than this time (overrides INI value)
--clean-latest also clean 'latest' tags (by default they're excluded from removal)
--clean-all delete all images in repository (DANGER!)
--single-tag only delete images with one tag (no 'co-tag' delete)
--dry-run not delete actually
-z, --insecure disable SSL certificate verification
-v, --verbose verbose mode
--debug debug outputTo work requires settings in the INI file or environment variables
```### Final disk cleanup
`gitlab-registry-images-cleaner` only "soft" deletes the images. Their data (image layers) are still stored.
To delete those, you must run Docker registry GC. With GitLab omnibus package, it's possible with the following commands:```bash
sudo gitlab-ctl registry-garbage-collect -m
```### Use Docker image
```
docker pull n0madic/gricleaner:latest
docker run --rm -e GITLAB_REGISTRY -e GITLAB_JWT_URL -e GITLAB_USER -e GITLAB_PASSWORD n0madic/gricleaner:latest -r group/project ...
```