Easy delete manifests and images from your own registry
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
This project's aim is to delete unnecessary images and manifests from your own docker registry. Azure container registry (aka ACR) has purge command, Gitlab registry has a cleanup policy, etc. Registry-cleaner has a configuration for custom rules like GitLab cleanup policy.
- Get a release compatible your system from github.
Or
- Clone the repo
git clone https://github.com/onuryartasi/regitry-cleaner.git
- Install go modules.
go mod download
- Build source code.
go build -o registry-cleaner main.go
- Configure your rules
config.yaml
regex: enable: true pattern: - group/image-name
Before usage this tool enable delete function from registry.(https://docs.docker.com/registry/configuration/#delete). You can use env variable REGISTRY_STORAGE_DELETE_ENABLED=true
for deletable registry from api.
See parameters.
-config-file string
Config file path. (default "config.yaml")
-dry-run
Print deletable images, don't remove.
-host string
Registry host (default "localhost")
-password string
Registry password
-username string
Registry username
Before use to registry-cleaner
configure your own rules for according to your needs.
There is a example config file.
#Regex pattern, you can run own regex rules for images.
regex:
# If you enable false can't apply this pattern on your images.
enable: true
pattern:
# Delete images to match those pattern. Multi pattern accaptable.
- g1/hello-world
- g2*
# Until-date pattern, when give a date delete all images before this date.
until-date:
enable: true
#### Example date layout
### 02.01.2006 15:04:05
### 02.01.2006 15:04
### 02.01.2006
date: "31.05.2021"
# N pattern, just latest n images will be stored. other images will be delete.
n:
enable: false
size: 10 # Number of to image to keeping.
registry-cleaner -host http://localhost:5000 -config-file="config.yaml"
registry-cleaner -host http://localhost:5000 -username admin -password changeme -config-file="config.yaml"
After all of them, manually run a garbage collector in your registry if you want to immediately delete images.
registry garbage-collect /etc/docker/registry/config.yml
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazinFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.md
for more information.