If you're hosting a private Docker Registry backed by local storage then you may have noticed the servers available disk space decreasing over time.

If you're running low on disk space then you might be happy to know that we can get away with using some curl and skopeo to remove outdated resources.

List repositories

curl https://${DOCKER_USERNAME}:${DOCKER_PASSWORD}@${DOCKER_REGISTRY}/v2/_catalog |jq

List tags

docker run --rm \
    -v ${HOME}/.docker/config.json:/root/.docker/config.json \
    lazybit/skopeo list-tags docker://${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}

Delete tag

docker run --rm \
    -v ${HOME}/.docker/config.json:/root/.docker/config.json \
    lazybit/skopeo delete docker://${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}:${DOCKER_TAG}

Collect garbage

registry \
    garbage-collect \
    /etc/docker/registry/config.yml \
    --delete-untagged=true