Skip to content

Instantly share code, notes, and snippets.

View mortensteenrasmussen's full-sized avatar

Morten Steen Rasmussen mortensteenrasmussen

View GitHub Profile
@mortensteenrasmussen
mortensteenrasmussen / cleanupManifestsWithoutTags.sh
Last active September 9, 2024 08:12
Clean up untagged manifests in private docker registry
#!/bin/bash
REGISTRY_DIR=YOUR_REGISTRY_DIR/data/docker/registry/v2/repositories
REGISTRY_URL=http://10.10.10.10:5000
#add --insecure to the curl command on line 17 if you use https with self-signed certificates
cd ${REGISTRY_DIR}
count=0
manifests_without_tags=$(comm -23 <(find . -type f -name "link" | grep "_manifests/revisions/sha256" | grep -v "\/signatures\/sha256\/" | awk -F/ '{print $(NF-1)}' | sort) <(for f in $(find . -type f -name "link" | grep "_manifests/tags/.*/current/link"); do cat ${f} | sed 's/^sha256://g'; echo; done | sort))