I have routed all gcr.io traffic to Artifact Registry. The command gcloud container images delete --force-delete-tags
used to delete digests in an image along with the image. Now with the images hosted on Artifact Registry, the command still deletes digests but leaves an empty image. I would like to be able to delete the image via command line for automation purposes. How can I do this?
You can, in fact, perform commands on gcr.io container images routed to artifact registry using gcloud artifacts
commands. The trick is to use the correct location in the LOCATION-docker.pkg.dev
syntax, which proved difficult to find. For gcr.io images the location is just us
, giving us-docker.pkg.dev
.
Therefore, for an image that looks like
us.gcr.io/my-project/appengine/default.12345
use this command to delete it:
gcloud artifacts docker images delete \
us-docker.pkg.dev/my-project/us.gcr.io/appengine/default.12345
It took trying a lot of things, but I finally got it by clicking on "Setup Instructions" in the console in the repo, which showed the valuable "us-docker.pkg.dev" in instructions for configuring Docker.
My suggestion for the console is that at the top left where you can see and copy the repository path, for gcr.io repos, don't have us.gcr.io/my-project
like is currently there, but have us-docker.pkg.dev/my-project/us.gcr.io
instead.