Created
August 2, 2018 13:52
-
-
Save ruxkor/796ebc2866581195c36110f85e8712c8 to your computer and use it in GitHub Desktop.
delete a specific image in your docker registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# set the following variables | |
REGISTRY_HOSTNAME= | |
REGISTRY_USER= | |
REGISTRY_PASSWORD= | |
REGISTRY_IMAGE= | |
REGISTRY_IMAGE_TAG= | |
# if you don't know, get the tags first | |
# curl -sSL "https://${REGISTRY_USER}:${REGISTRY_PASSWORD}@${REGISTRY_HOSTNAME}/v2/${REGISTRY_IMAGE}/tags/list" | jq -r '.tags' | |
REGISTRY_IMAGE_DIGEST=$(curl -sSL -I -H "Accept: application/vnd.docker.distribution.manifest.v2+json" "https://${REGISTRY_USER}:${REGISTRY_PASSWORD}@${REGISTRY_HOSTNAME}/v2/${REGISTRY_IMAGE}/manifests/${REGISTRY_IMAGE_TAG}" | awk '$1 == "docker-content-digest:" { print $2 }' | tr -d $'\r') | |
curl -v -sSL -X DELETE "https://${REGISTRY_USER}:${REGISTRY_PASSWORD}@${REGISTRY_HOSTNAME}/v2/${REGISTRY_IMAGE}/manifests/${REGISTRY_IMAGE_DIGEST}" 2>&1 | grep '< HTTP' | |
# should return 204 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment