you need jq
first.
Steps:
- download the script && chmod +x
- enable "delete" inside docker registry container
/etc/docker/registry/config.yml
storage:
delete:
enabled: true
- restart registry container
- exec script (note: you can use
2>&1 | tee
to output the result to both a file and standard output) docker exec -it {registry-id} /bin/registry garbage-collect /etc/docker/registry/config.yml
- stop registry container && start registry container
Thanks a lot! Here is also an adapted version for Nexus (basic auth) https://gist.github.com/smnbbrv/55cc0b2a0a30f56f7744fe75fbf9676c and semantic versioning