Last active
August 25, 2016 14:27
-
-
Save mping/8e4f3dfafc40b2527ef3f5549f05bec6 to your computer and use it in GitHub Desktop.
Remove image from 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
def deleteImageWithTagAndHash(registryHost, imageName, tag, hash) | |
puts "Deleting..." | |
res = `curl -X DELETE -I http://#{registryHost}/v2/#{imageName}/manifests/#{hash}` | |
puts "curl -X DELETE -I http://#{registryHost}/v2/#{imageName}/manifests/#{hash}" | |
puts "Deleted image with tag #{tag}" | |
end | |
def getDigestForImageAndTag(registryHost, imageName, tag) | |
puts 'Processing...' | |
digestHash = `curl -s -I -X HEAD -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' http://#{registryHost}/v2/#{imageName}/manifests/#{tag} | sed -n 's/Docker-Content-Digest://p'` | |
puts "curl -s -I -X HEAD -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' http://#{registryHost}/v2/#{imageName}/manifests/#{tag} | sed -n 's/Docker-Content-Digest://p'" | |
digestHash.strip | |
end | |
def cleanup(registryHost) | |
def executeCleanup(registryHost) { | |
out = `DOCKER_API_VERSION=1.22 docker -H \"tcp://${registryHost}:2375\" exec -it docker-registry01 bin/registry garbage-collect /etc/docker/registry/config.yml` | |
out | |
} | |
end | |
hash = getDigestForImageAndTag("lismgtreg01.athepg.bskyb.com", "hapi-api", "2.0.1-SNAPSHOT-e62427aa2897380649456118741f0b2c6be1fbec") | |
deleteImageWithTagAndHash("lismgtreg01.athepg.bskyb.com", "hapi-api", "2.0.1-SNAPSHOT-e62427aa2897380649456118741f0b2c6be1fbec", hash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment