Last active
December 12, 2016 12:15
-
-
Save 1ma/12e1d6f956b2aa3be7d367af1ba9aab9 to your computer and use it in GitHub Desktop.
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
<?php | |
// After this run the registry garbage collector, | |
// it will mark new blob layers for removal: | |
// $ docker exec registry registry garbage-collect [--dry-run] /etc/docker/registry/config.yml | |
require_once __DIR__.'/vendor/autoload.php'; | |
$apiBaseURI = 'https://registry.example.com:5000'; | |
$image = 'projectx/nginx'; | |
$tags = [ | |
"ce06f6fc35a883d2297dd18b5de0b65d0b0a6d52", | |
"f806a952e287de043e139613da3f034b9db14882", | |
"b62a9aa7b0ae12da63ef321e2f9fe3de871bd872", | |
"b7fb5f9a78b450fcc8cc5bf7e18186a3d76ef97c", | |
"04a5df5c01cca9cf96ea9baa4aeed8ac17309b2e", | |
"2b4c831d2c99de85a844386405e18b905dc2d54b", | |
"65f237aeca412a13b19e7eb7c6d6b83467eb4557", | |
"c67ef6d8fdb6a5fca08e867296418f9b21657d92", | |
"80e5cf1695a9d9d57db9307077622ed4ca05d63d", | |
"3098e7bfa20d4f5413d372afa59797aba984c4bc", | |
"78dcca7c1cc07c10a9cb1a4a6356251d4bf80c3d", | |
"1f1624e53efbc310c45220ca17a7834f693d6834", | |
"28858387e53dd95ad73a617a0bef2a79df648b20", | |
"8ea9222e6e007f3f85a2feebcd2214776be08245", | |
"ca3933e59c933726f46dedd32b3c893636921fbc", | |
"7a27ba5692f5af422e06702f8dd147e3713d6175", | |
"ca52d72cbc1b99e7d921e36b245ab88644e18909", | |
"ba8004cf755bd368a0d1815de482ec292c0009b3", | |
"7391cb615543e108b2681751c782d789b4046aba", | |
"890735e9094a6f292606eb7998a714ed537016bf", | |
"e07e67c21fc468f7f3ac8fdc0f4665507dbc41e5", | |
"690bcb93b145ebd9a8a6b44e4b1770f79f8ede2e", | |
"0aa621d9587721e0091f50f12818ee710b0e1832", | |
"9dd2bce18f67d0690b4dd4af0f330de75e42688c", | |
"5d1ede32486767357185f485cfee800c00658d3c", | |
"dc4a8b2f41fe2aa656406b2bd4623b0eaaf5dad4", | |
"ea2e65b001fbb8bd924de2d6b8cdfb31176581a8", | |
"b68230cb6c76f2b47b248b0f5661ac285add967c", | |
"f3262cdd83a50f5ff3aa81a691b6d725c312472b", | |
"latest", | |
]; | |
$client = new \GuzzleHttp\Client(['base_uri' => $apiBaseURI, 'http_errors' => false]); | |
print "image: $image\n\n"; | |
foreach ($tags as $tag) { | |
$reference = $client->head( | |
"/v2/$image/manifests/$tag", | |
['headers' => ['Accept' => 'application/vnd.docker.distribution.manifest.v2+json']] | |
)->getHeaderLine('Docker-Content-Digest'); | |
$status = @$client->delete("/v2/$image/manifests/$reference") | |
->getStatusCode(); | |
print "tag: $tag, status: $status\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment