How can I list and delete GCP AppEngine images from the command line?












1















I'd like to delete my old unused AppEngine images from Google Cloud Platform, so that I'm not charged for storing them.



I can manually list and delete the images created for my GCP AppEngine project from this URL:
https://console.cloud.google.com/gcr/images/GOOGLE_CLOUD_PROJECT_ID



(Obviously, replace GOOGLE_CLOUD_PROJECT_ID with an appropriate GCP project id.)



Is there a way to list them from the command line? e.g. via gcloud?



This doesn't work as I would expect:



$ gcloud compute images list --no-standard-images
Listed 0 items.


Neither does this:



$ gcloud container images list 
Listed 0 items.
Only listing images in gcr.io/GOOGLE_CLOUD_PROJECT_ID. Use --repository to list images in other repositories.


It's a little painful to go in and delete lots of these manually since each image under https://console.cloud.google.com/gcr/images/GOOGLE_CLOUD_PROJECT_ID/US/appengine is in a separate directory that I have to first click into to select the image and then click the delete button, and then go back out to the appengine directory and start the process again for any other images.










share|improve this question

























  • I'm not a flex env user, but maybe try to see if gcloud app versions list|delete and/or gcloud app services list|delete can do what you want as a side effect of deleting versions/services.

    – Dan Cornilescu
    Nov 14 '18 at 2:44








  • 1





    @DanCornilescu, thanks, those commands match what I see at console.cloud.google.com/appengine/versions but when I delete an old version (via the website) it doesn't automatically delete the corresponding image.

    – Rohan Talip
    Nov 14 '18 at 5:21


















1















I'd like to delete my old unused AppEngine images from Google Cloud Platform, so that I'm not charged for storing them.



I can manually list and delete the images created for my GCP AppEngine project from this URL:
https://console.cloud.google.com/gcr/images/GOOGLE_CLOUD_PROJECT_ID



(Obviously, replace GOOGLE_CLOUD_PROJECT_ID with an appropriate GCP project id.)



Is there a way to list them from the command line? e.g. via gcloud?



This doesn't work as I would expect:



$ gcloud compute images list --no-standard-images
Listed 0 items.


Neither does this:



$ gcloud container images list 
Listed 0 items.
Only listing images in gcr.io/GOOGLE_CLOUD_PROJECT_ID. Use --repository to list images in other repositories.


It's a little painful to go in and delete lots of these manually since each image under https://console.cloud.google.com/gcr/images/GOOGLE_CLOUD_PROJECT_ID/US/appengine is in a separate directory that I have to first click into to select the image and then click the delete button, and then go back out to the appengine directory and start the process again for any other images.










share|improve this question

























  • I'm not a flex env user, but maybe try to see if gcloud app versions list|delete and/or gcloud app services list|delete can do what you want as a side effect of deleting versions/services.

    – Dan Cornilescu
    Nov 14 '18 at 2:44








  • 1





    @DanCornilescu, thanks, those commands match what I see at console.cloud.google.com/appengine/versions but when I delete an old version (via the website) it doesn't automatically delete the corresponding image.

    – Rohan Talip
    Nov 14 '18 at 5:21
















1












1








1








I'd like to delete my old unused AppEngine images from Google Cloud Platform, so that I'm not charged for storing them.



I can manually list and delete the images created for my GCP AppEngine project from this URL:
https://console.cloud.google.com/gcr/images/GOOGLE_CLOUD_PROJECT_ID



(Obviously, replace GOOGLE_CLOUD_PROJECT_ID with an appropriate GCP project id.)



Is there a way to list them from the command line? e.g. via gcloud?



This doesn't work as I would expect:



$ gcloud compute images list --no-standard-images
Listed 0 items.


Neither does this:



$ gcloud container images list 
Listed 0 items.
Only listing images in gcr.io/GOOGLE_CLOUD_PROJECT_ID. Use --repository to list images in other repositories.


It's a little painful to go in and delete lots of these manually since each image under https://console.cloud.google.com/gcr/images/GOOGLE_CLOUD_PROJECT_ID/US/appengine is in a separate directory that I have to first click into to select the image and then click the delete button, and then go back out to the appengine directory and start the process again for any other images.










share|improve this question
















I'd like to delete my old unused AppEngine images from Google Cloud Platform, so that I'm not charged for storing them.



I can manually list and delete the images created for my GCP AppEngine project from this URL:
https://console.cloud.google.com/gcr/images/GOOGLE_CLOUD_PROJECT_ID



(Obviously, replace GOOGLE_CLOUD_PROJECT_ID with an appropriate GCP project id.)



Is there a way to list them from the command line? e.g. via gcloud?



This doesn't work as I would expect:



$ gcloud compute images list --no-standard-images
Listed 0 items.


Neither does this:



$ gcloud container images list 
Listed 0 items.
Only listing images in gcr.io/GOOGLE_CLOUD_PROJECT_ID. Use --repository to list images in other repositories.


It's a little painful to go in and delete lots of these manually since each image under https://console.cloud.google.com/gcr/images/GOOGLE_CLOUD_PROJECT_ID/US/appengine is in a separate directory that I have to first click into to select the image and then click the delete button, and then go back out to the appengine directory and start the process again for any other images.







google-app-engine google-cloud-platform gcloud google-container-registry






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 24 '18 at 11:16









LundinCast

2,45341322




2,45341322










asked Nov 14 '18 at 2:00









Rohan TalipRohan Talip

715




715













  • I'm not a flex env user, but maybe try to see if gcloud app versions list|delete and/or gcloud app services list|delete can do what you want as a side effect of deleting versions/services.

    – Dan Cornilescu
    Nov 14 '18 at 2:44








  • 1





    @DanCornilescu, thanks, those commands match what I see at console.cloud.google.com/appengine/versions but when I delete an old version (via the website) it doesn't automatically delete the corresponding image.

    – Rohan Talip
    Nov 14 '18 at 5:21





















  • I'm not a flex env user, but maybe try to see if gcloud app versions list|delete and/or gcloud app services list|delete can do what you want as a side effect of deleting versions/services.

    – Dan Cornilescu
    Nov 14 '18 at 2:44








  • 1





    @DanCornilescu, thanks, those commands match what I see at console.cloud.google.com/appengine/versions but when I delete an old version (via the website) it doesn't automatically delete the corresponding image.

    – Rohan Talip
    Nov 14 '18 at 5:21



















I'm not a flex env user, but maybe try to see if gcloud app versions list|delete and/or gcloud app services list|delete can do what you want as a side effect of deleting versions/services.

– Dan Cornilescu
Nov 14 '18 at 2:44







I'm not a flex env user, but maybe try to see if gcloud app versions list|delete and/or gcloud app services list|delete can do what you want as a side effect of deleting versions/services.

– Dan Cornilescu
Nov 14 '18 at 2:44






1




1





@DanCornilescu, thanks, those commands match what I see at console.cloud.google.com/appengine/versions but when I delete an old version (via the website) it doesn't automatically delete the corresponding image.

– Rohan Talip
Nov 14 '18 at 5:21







@DanCornilescu, thanks, those commands match what I see at console.cloud.google.com/appengine/versions but when I delete an old version (via the website) it doesn't automatically delete the corresponding image.

– Rohan Talip
Nov 14 '18 at 5:21














2 Answers
2






active

oldest

votes


















2














The link to the Developer Console you provided refers to the Container Registry, where your container images are stored, including those created during App Engine Flexible deployments.



You can list these images by location using the following gcloud command:



gcloud container images list --repository=[HOSTNAME]/[PROJECT-ID]


where [HOSTNAME] is one of four options: gcr.io, us.gcr.io, eu.gcr.io, or asia.gcr.io.



You can then delete images using the following command:



gcloud container images delete [HOSTNAME]/[PROJECT-ID]/[IMAGE]@[IMAGE_DIGEST]


You'll find detailed information about it in the online documentation.






share|improve this answer
























  • Thanks, I missed that there were other options for the hostname. In my case, I needed to use us.gcr.io. There is a little more that I had to do; I'll put that in a separate answer.

    – Rohan Talip
    Nov 14 '18 at 18:09



















2














Listing images



Thanks to LundinCast's answer, I used us.gcr.io as the hostname and I was able to do this:



$ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID
NAME
us.gcr.io/GCP_PROJECT_ID/appengine


Apparently AppEngine uses a nested repository:



$ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine
NAME
us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t162317
us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t132223
us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t150454
us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t184629
us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t205831
us.gcr.io/GCP_PROJECT_ID/appengine/DEF.20181113t163644


This didn't work as I expected though:



$ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
Listed 0 items.


Instead, I had to do:



$ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
DIGEST TAGS TIMESTAMP
c8e3797d36b2 latest 2018-11-10T12:57:58


Deleting images



According to the documentation for deleting images, it is possible to delete ...




  • An image identified by its digest

  • An image identified by its tag, and it has multiple tags


Deleting images by (implicit) tag



When I tried to delete the single version / tag, I was shown a prompt:



$ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
Digests:
- us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
Associated tags:
- latest
Tags:
- us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
This operation will delete the tags and images identified by the
digests above.

Do you want to continue (Y/n)? n

ERROR: (gcloud.container.images.delete) Aborted by user.


This is a little problematic for writing a script or program that can delete old images automatically (although I could pipe the yes command into the gcloud container images delete IMAGE command); luckily there is a --quiet argument that can be used:



$ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 --quiet
WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
Digests:
- us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
Associated tags:
- latest
Tags:
- us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest].
Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181].


So, that worked.



Deleting images by digest



Trying again on another image, with the digest method of deleting images:



$ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
DIGEST TAGS TIMESTAMP
4d860e73f85f latest 2018-11-10T15:50:55


Surprise! You can't just use the digest as listed:



$ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f
ERROR: (gcloud.container.images.delete) [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f] digest must be of the form "sha256:<digest>".


This was a little odd (there's only one tag, "latest", and it's not even shown in the error) :



$ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f
ERROR: Tags:
ERROR: (gcloud.container.images.delete) This operation will implicitly delete the tags listed above. Please manually remove with the `untag` command or re-run with --force-delete-tags to confirm.


OK, let's use --force-delete-tags :



$ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags
Digests:
- us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
Associated tags:
- latest
This operation will delete the tags and images identified by the digests above.

Do you want to continue (Y/n)? n

ERROR: (gcloud.container.images.delete) Aborted by user.


As before, let's use --quiet to prevent showing the prompt:



$ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags --quiet
Digests:
- us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
Associated tags:
- latest
Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726:latest].
Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542].


So, deleting by digest requires a more verbose command line.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292130%2fhow-can-i-list-and-delete-gcp-appengine-images-from-the-command-line%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    The link to the Developer Console you provided refers to the Container Registry, where your container images are stored, including those created during App Engine Flexible deployments.



    You can list these images by location using the following gcloud command:



    gcloud container images list --repository=[HOSTNAME]/[PROJECT-ID]


    where [HOSTNAME] is one of four options: gcr.io, us.gcr.io, eu.gcr.io, or asia.gcr.io.



    You can then delete images using the following command:



    gcloud container images delete [HOSTNAME]/[PROJECT-ID]/[IMAGE]@[IMAGE_DIGEST]


    You'll find detailed information about it in the online documentation.






    share|improve this answer
























    • Thanks, I missed that there were other options for the hostname. In my case, I needed to use us.gcr.io. There is a little more that I had to do; I'll put that in a separate answer.

      – Rohan Talip
      Nov 14 '18 at 18:09
















    2














    The link to the Developer Console you provided refers to the Container Registry, where your container images are stored, including those created during App Engine Flexible deployments.



    You can list these images by location using the following gcloud command:



    gcloud container images list --repository=[HOSTNAME]/[PROJECT-ID]


    where [HOSTNAME] is one of four options: gcr.io, us.gcr.io, eu.gcr.io, or asia.gcr.io.



    You can then delete images using the following command:



    gcloud container images delete [HOSTNAME]/[PROJECT-ID]/[IMAGE]@[IMAGE_DIGEST]


    You'll find detailed information about it in the online documentation.






    share|improve this answer
























    • Thanks, I missed that there were other options for the hostname. In my case, I needed to use us.gcr.io. There is a little more that I had to do; I'll put that in a separate answer.

      – Rohan Talip
      Nov 14 '18 at 18:09














    2












    2








    2







    The link to the Developer Console you provided refers to the Container Registry, where your container images are stored, including those created during App Engine Flexible deployments.



    You can list these images by location using the following gcloud command:



    gcloud container images list --repository=[HOSTNAME]/[PROJECT-ID]


    where [HOSTNAME] is one of four options: gcr.io, us.gcr.io, eu.gcr.io, or asia.gcr.io.



    You can then delete images using the following command:



    gcloud container images delete [HOSTNAME]/[PROJECT-ID]/[IMAGE]@[IMAGE_DIGEST]


    You'll find detailed information about it in the online documentation.






    share|improve this answer













    The link to the Developer Console you provided refers to the Container Registry, where your container images are stored, including those created during App Engine Flexible deployments.



    You can list these images by location using the following gcloud command:



    gcloud container images list --repository=[HOSTNAME]/[PROJECT-ID]


    where [HOSTNAME] is one of four options: gcr.io, us.gcr.io, eu.gcr.io, or asia.gcr.io.



    You can then delete images using the following command:



    gcloud container images delete [HOSTNAME]/[PROJECT-ID]/[IMAGE]@[IMAGE_DIGEST]


    You'll find detailed information about it in the online documentation.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 14 '18 at 9:06









    LundinCastLundinCast

    2,45341322




    2,45341322













    • Thanks, I missed that there were other options for the hostname. In my case, I needed to use us.gcr.io. There is a little more that I had to do; I'll put that in a separate answer.

      – Rohan Talip
      Nov 14 '18 at 18:09



















    • Thanks, I missed that there were other options for the hostname. In my case, I needed to use us.gcr.io. There is a little more that I had to do; I'll put that in a separate answer.

      – Rohan Talip
      Nov 14 '18 at 18:09

















    Thanks, I missed that there were other options for the hostname. In my case, I needed to use us.gcr.io. There is a little more that I had to do; I'll put that in a separate answer.

    – Rohan Talip
    Nov 14 '18 at 18:09





    Thanks, I missed that there were other options for the hostname. In my case, I needed to use us.gcr.io. There is a little more that I had to do; I'll put that in a separate answer.

    – Rohan Talip
    Nov 14 '18 at 18:09













    2














    Listing images



    Thanks to LundinCast's answer, I used us.gcr.io as the hostname and I was able to do this:



    $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID
    NAME
    us.gcr.io/GCP_PROJECT_ID/appengine


    Apparently AppEngine uses a nested repository:



    $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine
    NAME
    us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
    us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
    us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t162317
    us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t132223
    us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t150454
    us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t184629
    us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t205831
    us.gcr.io/GCP_PROJECT_ID/appengine/DEF.20181113t163644


    This didn't work as I expected though:



    $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
    Listed 0 items.


    Instead, I had to do:



    $ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
    DIGEST TAGS TIMESTAMP
    c8e3797d36b2 latest 2018-11-10T12:57:58


    Deleting images



    According to the documentation for deleting images, it is possible to delete ...




    • An image identified by its digest

    • An image identified by its tag, and it has multiple tags


    Deleting images by (implicit) tag



    When I tried to delete the single version / tag, I was shown a prompt:



    $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
    WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
    Digests:
    - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
    Associated tags:
    - latest
    Tags:
    - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
    This operation will delete the tags and images identified by the
    digests above.

    Do you want to continue (Y/n)? n

    ERROR: (gcloud.container.images.delete) Aborted by user.


    This is a little problematic for writing a script or program that can delete old images automatically (although I could pipe the yes command into the gcloud container images delete IMAGE command); luckily there is a --quiet argument that can be used:



    $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 --quiet
    WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
    Digests:
    - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
    Associated tags:
    - latest
    Tags:
    - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
    Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest].
    Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181].


    So, that worked.



    Deleting images by digest



    Trying again on another image, with the digest method of deleting images:



    $ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
    DIGEST TAGS TIMESTAMP
    4d860e73f85f latest 2018-11-10T15:50:55


    Surprise! You can't just use the digest as listed:



    $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f
    ERROR: (gcloud.container.images.delete) [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f] digest must be of the form "sha256:<digest>".


    This was a little odd (there's only one tag, "latest", and it's not even shown in the error) :



    $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f
    ERROR: Tags:
    ERROR: (gcloud.container.images.delete) This operation will implicitly delete the tags listed above. Please manually remove with the `untag` command or re-run with --force-delete-tags to confirm.


    OK, let's use --force-delete-tags :



    $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags
    Digests:
    - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
    Associated tags:
    - latest
    This operation will delete the tags and images identified by the digests above.

    Do you want to continue (Y/n)? n

    ERROR: (gcloud.container.images.delete) Aborted by user.


    As before, let's use --quiet to prevent showing the prompt:



    $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags --quiet
    Digests:
    - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
    Associated tags:
    - latest
    Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726:latest].
    Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542].


    So, deleting by digest requires a more verbose command line.






    share|improve this answer






























      2














      Listing images



      Thanks to LundinCast's answer, I used us.gcr.io as the hostname and I was able to do this:



      $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID
      NAME
      us.gcr.io/GCP_PROJECT_ID/appengine


      Apparently AppEngine uses a nested repository:



      $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine
      NAME
      us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
      us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
      us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t162317
      us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t132223
      us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t150454
      us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t184629
      us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t205831
      us.gcr.io/GCP_PROJECT_ID/appengine/DEF.20181113t163644


      This didn't work as I expected though:



      $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
      Listed 0 items.


      Instead, I had to do:



      $ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
      DIGEST TAGS TIMESTAMP
      c8e3797d36b2 latest 2018-11-10T12:57:58


      Deleting images



      According to the documentation for deleting images, it is possible to delete ...




      • An image identified by its digest

      • An image identified by its tag, and it has multiple tags


      Deleting images by (implicit) tag



      When I tried to delete the single version / tag, I was shown a prompt:



      $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
      WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
      Digests:
      - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
      Associated tags:
      - latest
      Tags:
      - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
      This operation will delete the tags and images identified by the
      digests above.

      Do you want to continue (Y/n)? n

      ERROR: (gcloud.container.images.delete) Aborted by user.


      This is a little problematic for writing a script or program that can delete old images automatically (although I could pipe the yes command into the gcloud container images delete IMAGE command); luckily there is a --quiet argument that can be used:



      $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 --quiet
      WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
      Digests:
      - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
      Associated tags:
      - latest
      Tags:
      - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
      Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest].
      Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181].


      So, that worked.



      Deleting images by digest



      Trying again on another image, with the digest method of deleting images:



      $ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
      DIGEST TAGS TIMESTAMP
      4d860e73f85f latest 2018-11-10T15:50:55


      Surprise! You can't just use the digest as listed:



      $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f
      ERROR: (gcloud.container.images.delete) [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f] digest must be of the form "sha256:<digest>".


      This was a little odd (there's only one tag, "latest", and it's not even shown in the error) :



      $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f
      ERROR: Tags:
      ERROR: (gcloud.container.images.delete) This operation will implicitly delete the tags listed above. Please manually remove with the `untag` command or re-run with --force-delete-tags to confirm.


      OK, let's use --force-delete-tags :



      $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags
      Digests:
      - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
      Associated tags:
      - latest
      This operation will delete the tags and images identified by the digests above.

      Do you want to continue (Y/n)? n

      ERROR: (gcloud.container.images.delete) Aborted by user.


      As before, let's use --quiet to prevent showing the prompt:



      $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags --quiet
      Digests:
      - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
      Associated tags:
      - latest
      Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726:latest].
      Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542].


      So, deleting by digest requires a more verbose command line.






      share|improve this answer




























        2












        2








        2







        Listing images



        Thanks to LundinCast's answer, I used us.gcr.io as the hostname and I was able to do this:



        $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID
        NAME
        us.gcr.io/GCP_PROJECT_ID/appengine


        Apparently AppEngine uses a nested repository:



        $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine
        NAME
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t162317
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t132223
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t150454
        us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t184629
        us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t205831
        us.gcr.io/GCP_PROJECT_ID/appengine/DEF.20181113t163644


        This didn't work as I expected though:



        $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
        Listed 0 items.


        Instead, I had to do:



        $ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
        DIGEST TAGS TIMESTAMP
        c8e3797d36b2 latest 2018-11-10T12:57:58


        Deleting images



        According to the documentation for deleting images, it is possible to delete ...




        • An image identified by its digest

        • An image identified by its tag, and it has multiple tags


        Deleting images by (implicit) tag



        When I tried to delete the single version / tag, I was shown a prompt:



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
        WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
        Digests:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
        Associated tags:
        - latest
        Tags:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
        This operation will delete the tags and images identified by the
        digests above.

        Do you want to continue (Y/n)? n

        ERROR: (gcloud.container.images.delete) Aborted by user.


        This is a little problematic for writing a script or program that can delete old images automatically (although I could pipe the yes command into the gcloud container images delete IMAGE command); luckily there is a --quiet argument that can be used:



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 --quiet
        WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
        Digests:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
        Associated tags:
        - latest
        Tags:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
        Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest].
        Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181].


        So, that worked.



        Deleting images by digest



        Trying again on another image, with the digest method of deleting images:



        $ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
        DIGEST TAGS TIMESTAMP
        4d860e73f85f latest 2018-11-10T15:50:55


        Surprise! You can't just use the digest as listed:



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f
        ERROR: (gcloud.container.images.delete) [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f] digest must be of the form "sha256:<digest>".


        This was a little odd (there's only one tag, "latest", and it's not even shown in the error) :



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f
        ERROR: Tags:
        ERROR: (gcloud.container.images.delete) This operation will implicitly delete the tags listed above. Please manually remove with the `untag` command or re-run with --force-delete-tags to confirm.


        OK, let's use --force-delete-tags :



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags
        Digests:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
        Associated tags:
        - latest
        This operation will delete the tags and images identified by the digests above.

        Do you want to continue (Y/n)? n

        ERROR: (gcloud.container.images.delete) Aborted by user.


        As before, let's use --quiet to prevent showing the prompt:



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags --quiet
        Digests:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
        Associated tags:
        - latest
        Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726:latest].
        Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542].


        So, deleting by digest requires a more verbose command line.






        share|improve this answer















        Listing images



        Thanks to LundinCast's answer, I used us.gcr.io as the hostname and I was able to do this:



        $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID
        NAME
        us.gcr.io/GCP_PROJECT_ID/appengine


        Apparently AppEngine uses a nested repository:



        $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine
        NAME
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t162317
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t132223
        us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181113t150454
        us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t184629
        us.gcr.io/GCP_PROJECT_ID/appengine/default.20181108t205831
        us.gcr.io/GCP_PROJECT_ID/appengine/DEF.20181113t163644


        This didn't work as I expected though:



        $ gcloud container images list --repository=us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
        Listed 0 items.


        Instead, I had to do:



        $ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
        DIGEST TAGS TIMESTAMP
        c8e3797d36b2 latest 2018-11-10T12:57:58


        Deleting images



        According to the documentation for deleting images, it is possible to delete ...




        • An image identified by its digest

        • An image identified by its tag, and it has multiple tags


        Deleting images by (implicit) tag



        When I tried to delete the single version / tag, I was shown a prompt:



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 
        WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
        Digests:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
        Associated tags:
        - latest
        Tags:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
        This operation will delete the tags and images identified by the
        digests above.

        Do you want to continue (Y/n)? n

        ERROR: (gcloud.container.images.delete) Aborted by user.


        This is a little problematic for writing a script or program that can delete old images automatically (although I could pipe the yes command into the gcloud container images delete IMAGE command); luckily there is a --quiet argument that can be used:



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425 --quiet
        WARNING: Implicit ":latest" tag specified: us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425
        Digests:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181
        Associated tags:
        - latest
        Tags:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest
        Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425:latest].
        Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t125425@sha256:c8e3797d36b27599c91e231afd5521e6a1283319fce5a0fd978b7cdcdb1d4181].


        So, that worked.



        Deleting images by digest



        Trying again on another image, with the digest method of deleting images:



        $ gcloud container images list-tags us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726
        DIGEST TAGS TIMESTAMP
        4d860e73f85f latest 2018-11-10T15:50:55


        Surprise! You can't just use the digest as listed:



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f
        ERROR: (gcloud.container.images.delete) [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@4d860e73f85f] digest must be of the form "sha256:<digest>".


        This was a little odd (there's only one tag, "latest", and it's not even shown in the error) :



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f
        ERROR: Tags:
        ERROR: (gcloud.container.images.delete) This operation will implicitly delete the tags listed above. Please manually remove with the `untag` command or re-run with --force-delete-tags to confirm.


        OK, let's use --force-delete-tags :



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags
        Digests:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
        Associated tags:
        - latest
        This operation will delete the tags and images identified by the digests above.

        Do you want to continue (Y/n)? n

        ERROR: (gcloud.container.images.delete) Aborted by user.


        As before, let's use --quiet to prevent showing the prompt:



        $ gcloud container images delete us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85f --force-delete-tags --quiet
        Digests:
        - us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542
        Associated tags:
        - latest
        Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726:latest].
        Deleted [us.gcr.io/GCP_PROJECT_ID/appengine/ABC.20181110t154726@sha256:4d860e73f85fdddb485e85dc867653e3e6095a5225f4f670200c98ede10fb542].


        So, deleting by digest requires a more verbose command line.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 14 '18 at 19:02

























        answered Nov 14 '18 at 18:32









        Rohan TalipRohan Talip

        715




        715






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292130%2fhow-can-i-list-and-delete-gcp-appengine-images-from-the-command-line%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python