Coder Social home page Coder Social logo

hjanuschka / delete-docker-registry-image Goto Github PK

View Code? Open in Web Editor NEW

This project forked from burnettk/delete-docker-registry-image

0.0 2.0 0.0 55 KB

If you are running a private v2 docker registry, and you are storing your data on disk, running this script from the machine where the data lives will let you fully delete an image or tag

License: MIT License

Python 67.16% Shell 32.84%

delete-docker-registry-image's Introduction

delete-docker-registry-image

Install

curl https://raw.githubusercontent.com/burnettk/delete-docker-registry-image/master/delete_docker_registry_image.py | sudo tee /usr/local/bin/delete_docker_registry_image >/dev/null
sudo chmod a+x /usr/local/bin/delete_docker_registry_image

Run

Set up your data directory via an environment variable:

export REGISTRY_DATA_DIR=/opt/registry_data/docker/registry/v2

You can also just edit the script where this variable is set to make it work for your setup.

Almost delete a repo:

delete_docker_registry_image --image testrepo/awesomeimage --dry-run

Actually delete a repo (remember to shut down your registry first):

delete_docker_registry_image --image testrepo/awesomeimage

Delete one tag from a repo:

delete_docker_registry_image --image testrepo/awesomeimage:supertag

clean_old_versions.py

This complimentary script is made to remove tags in repository based on regexp pattern.

Usage:

./clean_old_versions.py --image reg_exp_of_repository_to_find --include reg_exp_of_tag_to_find -l history_to_maintain --registry-url location_of_docker_registry -o tag_ordering -b only_tags_before_date -a only_tags_after_date

Example: Search for all images whose name start with 'repo/sitor' and delete all tags whose name start with '0.1.' keeping the last 2 tags and of the remaining tags deletes only those having an image creation time between January 1, 2016 12 a.m. and June 25, 2016 12 p.m. (both datetimes are exclusive).

./clean_old_versions.py --image '^repo/sitor*' --include '^0.1.*' -l 2 -b 2016-06-25T12:00:00 -a 2016-01-01T00:00:00 --registry-url http://localhost:5000

Add --dry-run as argument for a test run without actual removal of tags.

Run tests for this project

./test/start_up_vagrant_box_for_running_tests
vagrant ssh
cd /vagrant
./test/clean_and_run

Known test-passing configurations:

  1. docker: 1.9.1, registry:2.2.1
  2. docker: 1.10.2, registry:2.3.0
  3. docker: 1.11.2, registry:2.3.0
  4. docker: 1.12.1, registry:2.5.0

Known test-failing configurations:

  1. docker: 1.10.2, registry:2.2.1

When tests are run with a new docker daemon and an older registry, architecture-specific config files are created, but they are not referenced anywhere, so tests fail when we delete a tag or repo and expect all files to be deleted, but these architecture-specific config files are still hanging around. With the newer registry, these config files are referenced in the schema version 2 manifest, so we can easily delete them. It's probably best to avoid use of this script with the version combinations that fail tests.

Alternatives

Docker is building or has built much of this functionality in newer versions of docker and the registry.

The ability to delete the metadata for a manifest was added in registry:2.2. Make sure you give the registry the environment variable REGISTRY_STORAGE_DELETE_ENABLED=true. Follow the instructions at docker-archive/docker-registry#988 (comment) to delete a tag by name. Once the metadata is deleted, follow the instructions at https://github.com/docker/distribution/blob/master/docs/configuration.md to run garbage collection, which will clean up the binary data (the big stuff).

delete-docker-registry-image's People

Contributors

abulimov avatar burnettk avatar emtezogaf avatar rewiko avatar rtino avatar

Watchers

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