Search code examples
ibm-cloudcontainer-registryibm-cloud-kubernetes

IBM Cloud Container Registry: How to remove a group (or even all) of images using CLI


Checking with "ibmcloud cr images" I see I have several hundred old images in IBM Cloud container registry. Is there a way to delete them all, or delete by date? For example, images older than one year?

(Some shell script will probably do, of course...)


Solution

  • There are multiple options to remove many images at once from the IBM Cloud Container Registry:

    • Go to the browser console, then tick off the all box above the list, optionally deselect individual images, and click Delete images.
    • Using the command line and the IBM Cloud CLI, you could use ibmcloud cr image-prune-untagged (see here for syntax) to remove all images that are not explicitly tagged.
    • First, use something like ibmcloud cr image-list --format '{{.Repository}}@{{.Digest}}' to list all images and only print the repository and digest. Use this templating syntax to filter on some properties to reduce the list. Then, use that output list as input for ibmcloud cr image-rm (syntax).