Giter VIP home page Giter VIP logo

gitlab-registry-images-cleaner's Introduction

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 output

To 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:

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 ...

gitlab-registry-images-cleaner's People

Contributors

asyd avatar glensc avatar itaybb avatar n0madic avatar pyseed avatar svenbs avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.