Is it possible to remove a pushed image from Google Container Registry?
I mean without handling the Google Cloud Storage directory
I opened a ticket with Google for this same question and they responded back that it is not possible currently but to stay tuned because they do plan on adding it to the UI shortly.
In the meantime you have to use the storage browser to delete any that you want removed.
With current UI and its implementation, you can only delete tags, the underlying images will not be deleted.
If it is a Docker V2 images, from command line you can delete the image using Docker Registry API , by deleting the tags first, and then deleting the manifest. More about this at the end of the reply.
If it is a Docker V1 image, there is no "docker" way to delete the image, but you can delete the image in GCS.
We are implementing new features that will enable you to delete V2 tags and images.
Details about deleting V2 images/tags from command line using Docker Registry V2 API:
export REGISTRY=gcr.io
export REPOSITORY=foo/bar
# Next line will dump all the manifests and the tags pointing to the manifests:
curl -u _token:$(gcloud auth print-access-token) https://$REGISTRY/v2/$REPOSITORY/tags/list 2>/dev/null | python -mjson.tool
# You will see output like this:
{
...
"manifest": {
"sha256:2aa676...": {},
"sha256:95de3c...": {
"tag": [
"centos7.0.1406",
"centos8.8",
...
]
},
...
},
"name": "foo/bar",
"tags": [
"centos7.0.1406",
"centos8.8",
...
]
}
# Find the image/manifest you want to delete, first delete all its tags,
# then delete the manifest, by using:
curl -X DELETE -u _token:$(gcloud auth print-access-token) https://$REGISTRY/v2/$REPOSITORY/manifests/xxxx
# where xxxx is the tag or manifest you want to delete
# (yes, you delete tag and manifest using the same REST api)
Now that Google Container Registry migrated to v2, you can:
Remove manifests which will actually remove files and free space in your storage (use for example the Google Cloud Shell):
$ export REGISTRY=gcr.io
$ export REPOSITORY=my-registry-name/my-image-name
$ export TOKEN=$(gcloud auth print-access-token)
$ curl -u _token:$TOKEN https://$REGISTRY/v2/$REPOSITORY/tags/list 2>/dev/null | python -m json.tool | grep -Po 'sha256:[^"]*' | xargs -i sh -c "curl -X DELETE -u _token:$TOKEN https://$REGISTRY/v2/$REPOSITORY/manifests/{} 2>/dev/null | python -m json.tool"
Note: It'll not delete manifest that are used by tags.
Note 2: Once Docker Registry upgrades to v2.1.1 one may call GET /v2/_catalog
to list all images and run the above on all images to simplify the process.
Google Cloud Web UI allows now to delete images (see https://stackoverflow.com/a/33791574/167897)
Check how to delete images here.
Using CLI
gcloud container images delete [HOSTNAME]/[PROJECT-ID]/[IMAGE]
https://cloud.google.com/container-registry/docs/managing#deleting_images
As explained here you can delete an image from Google Container Registry with the following gcloud command:
gcloud container images delete IMAGE_NAMES [IMAGE_NAMES …] [GLOBAL-FLAG …]