All Projects → mortensteenrasmussen → Docker Registry Manifest Cleanup

mortensteenrasmussen / Docker Registry Manifest Cleanup

Licence: apache-2.0
Cleans up docker registry by removing untagged manifests from the registry

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Docker Registry Manifest Cleanup

Depot
Toolkit for storing files and attachments in web applications
Stars: ✭ 125 (-1.57%)
Mutual labels:  s3, s3-storage
Unburden Home Dir
Automatically unburden $HOME from caches, etc. Useful for $HOME on SSDs, small disks or slow NFS homes. Can be triggered via an hook in /etc/X11/Xsession.d/.
Stars: ✭ 48 (-62.2%)
Mutual labels:  disk-space, cleanup
Aws.s3
Amazon Simple Storage Service (S3) API Client
Stars: ✭ 302 (+137.8%)
Mutual labels:  s3, s3-storage
ionic-image-upload
Ionic Plugin for Uploading Images to Amazon S3
Stars: ✭ 26 (-79.53%)
Mutual labels:  s3, s3-storage
Oss Spring Boot Starter
兼容S3协议的通用文件存储工具类
Stars: ✭ 81 (-36.22%)
Mutual labels:  s3, s3-storage
Less3
Less3 is an S3-compatible object storage server that runs on your laptop, servers, just about anywhere!
Stars: ✭ 16 (-87.4%)
Mutual labels:  s3, s3-storage
Cortx
CORTX Community Object Storage is 100% open source object storage uniquely optimized for mass capacity storage devices.
Stars: ✭ 426 (+235.43%)
Mutual labels:  s3, s3-storage
s3cli
Command line tool for S3
Stars: ✭ 21 (-83.46%)
Mutual labels:  s3, s3-storage
Pierone
STUPS' Docker registry with S3 backend, immutable tags and SCM source tracking
Stars: ✭ 57 (-55.12%)
Mutual labels:  s3, docker-registry
Arc
📎 Flexible file upload and attachment library for Elixir
Stars: ✭ 1,087 (+755.91%)
Mutual labels:  s3, s3-storage
beekeeper
Service for automatically managing and cleaning up unreferenced data
Stars: ✭ 43 (-66.14%)
Mutual labels:  s3, cleanup
Sweep
Reduce the disk usage of your projects by removing dependencies & builds
Stars: ✭ 105 (-17.32%)
Mutual labels:  disk-space, cleanup
awesome-storage
A curated list of storage open source tools. Backups, redundancy, sharing, distribution, encryption, etc.
Stars: ✭ 324 (+155.12%)
Mutual labels:  s3, s3-storage
docker-registry-util
Search and cleanup on Docker Registry v2.
Stars: ✭ 27 (-78.74%)
Mutual labels:  docker-registry, cleanup
react-native-appsync-s3
React Native app for image uploads to S3 and storing their records in Amazon DynamoDB using AWS Amplify and AppSync SDK
Stars: ✭ 18 (-85.83%)
Mutual labels:  s3, s3-storage
Modclean
Remove unwanted files and directories from your node_modules folder
Stars: ✭ 309 (+143.31%)
Mutual labels:  disk-space, cleanup
Walrus
🔥 Fast, Secure and Reliable System Backup, Set up in Minutes.
Stars: ✭ 197 (+55.12%)
Mutual labels:  s3, s3-storage
terraform-aws-s3
Terraform module to create default S3 bucket with logging and encryption type specific features.
Stars: ✭ 22 (-82.68%)
Mutual labels:  s3, s3-storage
Tiledb
The Universal Storage Engine
Stars: ✭ 1,072 (+744.09%)
Mutual labels:  s3, s3-storage
Skrub
A package to remove junk from Composer installations and trim build sizes.
Stars: ✭ 91 (-28.35%)
Mutual labels:  disk-space, cleanup

Docker Registry(v2) Manifest Cleanup

Update note

Some variable names have changed, please check the documentation below if your script stopped working.

About

This script will search your registry and delete all manifests that do not have any tags associated. Deletion happens through the docker-registry API and should, therefore, be reasonably safe. After running this, you should do a garbage collect in the registry to free up the disk space.

Why does this happen?

Docker images can be pulled both via image:tag and via [email protected]. Because of this, if you overwrite an image:tag with a different one (e.g., pushing nightly to whateverimage:latest) you will still be able to pull the OLD versions of that tag by using [email protected]. This functionality means the registry garbage collect cannot remove an image because a reference still exists.

Isn't this a bug?

Not really, some people use [email protected] to make sure they pull the correct image to be certain that they get the right code in their project. Docker DAB files are one example of this.

There is; however, some work being done to make an API endpoint to find these 'hidden' manifests quickly. This work is being done in docker/distribution#2170 and docker/distribution#2169.

A feature request to be able to explicitly garbage collect untagged manifests is proposed in docker/distribution#1844.

This repo is meant as a workaround until we have the necessary tooling in Docker and registry to handle this without 3rd party tools.

Usage

Running against local storage

See the examples below if needed. Deletion needs to be enabled in your registry. See the Docker documentation

After running this, you should do a garbage collect in the registry to free up the disk space.

Variable name Required Description Example
REGISTRY_URL Yes The URL to the registry http://example.com:5000/
REGISTRY_DIR No The path to the registry dir - not needed if using the docker container and mounting in the dir in /registry (see examples) /registry
SELF_SIGNED_CERT No Set this if using a self-signed cert true
REGISTRY_AUTH No Set this when using http basic auth username:password
DRY_RUN No Set this to do a dry-run (e.g. don't delete anything, just show what would be done) true

Examples of running against local storage:

Simplest way:

docker run -it -v /home/someuser/registry:/registry -e REGISTRY_URL=http://192.168.77.88:5000 mortensrasmussen/docker-registry-manifest-cleanup

To test it without changing anything in your registry:

docker run -it -v /home/someuser/registry:/registry -e REGISTRY_URL=http://192.168.77.88:5000 -e DRY_RUN="true" mortensrasmussen/docker-registry-manifest-cleanup

With more options:

docker run -it -v /home/someuser/registry:/registry -e REGISTRY_URL=http://192.168.77.88:5000 -e SELF_SIGNED_CERT="true" -e REGISTRY_AUTH="myuser:sickpassword" mortensrasmussen/docker-registry-manifest-cleanup

Running against S3 storage

See the examples below if needed.

After running this, you should do a garbage collect in the registry to free up the disk space.

Variable name Required Description Example
REGISTRY_STORAGE Yes Tells the script to run against S3 S3
REGISTRY_URL Yes The URL to the registry http://example.com:5000/
ACCESS_KEY Yes The Accesskey to S3 XXXXXXGZMXXXXQMAGXXX
SECRET_KEY Yes The secret to S3 zfXXXXXEbq/JX++XXXAa/Z+ZCXXXXypfOXXXXC/X
BUCKET Yes The name of the bucket registry-bucket-1
REGION Yes The region in which the bucket is located eu-central-1
REGISTRY_DIR No Only needed if registry is not in the root folder of the bucket /path/to/registry
SELF_SIGNED_CERT No Set this if using a self-signed cert true
REGISTRY_AUTH No Set this when using http basic auth username:password
DRY_RUN No Set this to do a dry-run (e.g. don't delete anything, just show what would be done) true

Examples of running against S3 storage

Simplest way:

docker run -it -e REGISTRY_URL=http://192.168.77.88:5000 -e REGISTRY_STORAGE="S3" -e ACCESS_KEY="XXXXXXGZMXXXXQMAGXXX" -e SECRET_KEY="zfXXXXXEbq/JX++XXXAa/Z+ZCXXXXypfOXXXXC/X" -e BUCKET="registry-bucket-1" -e REGION="eu-central-1" mortensrasmussen/docker-registry-manifest-cleanup

To test it without changing anything in your registry:

docker run -it -e DRY_RUN="true" -e REGISTRY_URL=http://192.168.77.88:5000 -e REGISTRY_STORAGE="S3" -e ACCESS_KEY="XXXXXXGZMXXXXQMAGXXX" -e SECRET_KEY="zfXXXXXEbq/JX++XXXAa/Z+ZCXXXXypfOXXXXC/X" -e BUCKET="registry-bucket-1" -e REGION="eu-central-1" mortensrasmussen/docker-registry-manifest-cleanup

With more options:

docker run -it -e REGISTRY_URL=http://192.168.77.88:5000 -e REGISTRY_STORAGE="S3" -e ACCESS_KEY="XXXXXXGZMXXXXQMAGXXX" -e SECRET_KEY="zfXXXXXEbq/JX++XXXAa/Z+ZCXXXXypfOXXXXC/X" -e BUCKET="registry-bucket-1" -e REGION="eu-central-1" -e SELF_SIGNED_CERT="true" -e REGISTRY_AUTH="myuser:sickpassword" mortensrasmussen/docker-registry-manifest-cleanup

Running against Harbor and other baerer token-based authentication forms

The run should be the same, the only requirement is that the user:pass you provide should have full access to all repositories (and/or projects), since it needs to be able to delete manifests whereever its needed.

When running against Harbor, use a user that's in all projects as a project admin. When the run is finished, you can run the garbage collection through the Harbor UI.

This has been tested working in Harbor 1.7.0.

License

This project is distributed under Apache License, Version 2.0.

Copyright © 2018 Morten Steen Rasmussen

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].