Skip to content

Instantly share code, notes, and snippets.

@giansalex
Last active June 21, 2020 17:46
Show Gist options
  • Select an option

  • Save giansalex/5570002b6fb8d273d15bbc2ac4522aad to your computer and use it in GitHub Desktop.

Select an option

Save giansalex/5570002b6fb8d273d15bbc2ac4522aad to your computer and use it in GitHub Desktop.
Delete image from docker registrry

Delete image tag on Docker Registry v2

Require enable delete on docker-compose.yml.

environment:
  REGISTRY_STORAGE_DELETE_ENABLED: "true"

Run command to delete image tag.

# Yout registry Host 
HOST=registry.docker.com
CREDENTIALS="user:password"
IMAGE=example
TAG=latest

DIGEST=$(curl --silent -I -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -u $CREDENTIALS -X GET https://$HOST/v2/$IMAGE/manifests/$TAG 2>&1 | grep docker-content-digest | awk '{print ($2)}')
echo $DIGEST
curl -u $CREDENTIALS -X DELETE https://$HOST/v2/$IMAGE/manifests/$DIGEST

Finally, run garbage collector

docker exec -it docker-registry bin/registry garbage-collect /etc/docker/registry/config.yml --delete-untagged=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment