gcloud delete container image routed to artifact registry

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.

Since you’re now using Artifact Registry, you should use gcloud artifacts docker images delete. To delete an image with all of its digests and tags, use the following command:

gcloud artifacts docker images delete us-west1-docker.pkg.dev/my-project/my-repository/busy-box

Make sure that you follow the valid container image format when you’re deleting an image:

LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY-ID/IMAGE

Edit: The reason you’re only deleting the digest in the image is because gcloud container images delete requires you to use the format *.gcr.io/PROJECT_ID/IMAGE_PATH@sha256:DIGEST or *.gcr.io/PROJECT_ID/IMAGE_PATH:TAG. These are Container Registry paths which could explain the reason that your image stays in the Artifact Registry repository.

As a workaround, Take a look at Clean up images in Container Registry. Commands such as gcloud container images delete --force-delete-tags only deletes the image in the corresponding Artifact Registry gcr.io repository. It doesn’t actually delete the image stored in Container Registry. To remove Container Registry images, you have to delete the Cloud storage buckets for each Container Registry hostname.

To delete the bucket, use the gsutil rm command with the -r flag:

gsutil rm -r gs://BUCKET-NAME

Change the bucket name with the Container Registry storage bucket name along with your Project-ID: us.artifacts.PROJECT-ID.appspot.com

Feel free to edit this post.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật