Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Delete docker images via API?
-
Hello.
I'm writing a script that will cleanup old docker images created in our CI process.
I'm able to get the feeds, repositories, tags and images via the api.
The last step is to delete some images, and I can't find any way in the api documentation.Is there a way to delete docker images using the api?
My current workaround is delete the images using the web interface.
Best regards
Jonas LewinProduct: ProGet
Version: 4.7.11
-
UPDATE: this has been updated in PG-1632
__
Hello Jonas,
Deleting images isn't in the native API because the stored procedures only delete metadata, but if your CI server has access to the database ProGet is using, you can run the stored procedure to delete the metadata for the image and ProGet will automatically delete the files whenever the
FeedCleanup
scheduled task next runs.Assuming your docker image is named
proget:443/foo/bar/baz
, thefoo
feed has ID 42, and the digest for the version of the image you want to delete isf52fbd32b2b3b86ff88ef6c490628285f482af15ddcb29541f94bcf526a3f6c7
, this SQL statement will work:EXEC [DockerImages_DeleteImage] /* Feed_Id */ 42, /* Repository_Name*/ 'bar/baz', /* Image_Digest */ 'f52fbd32b2b3b86ff88ef6c490628285f482af15ddcb29541f94bcf526a3f6c7' GO
If you don't know the digest,
https://proget/api/json/DockerImages_GetImages?API_Key=
[your API key from /administration/api-keys]&Feed_Id=42&Repository_Name=bar/baz
returns metadata includingImage_Digest
andPublished_Date
, andhttps://proget/api/json/DockerImages_GetTags?API_Key=
[your API key from /administration/api-keys]&Feed_Id=42&Repository_Name=bar/baz
returns metadata includingImage_Digest
andTag_Name
.