How to get list of published docker images from GCP registry programmatically

Евгений Нагирный :

I'm trying to find some API (for example java, but could be some other) how to get published docker image names / tags from google cloud platform registry. I found how to do this using gcloud console commands:

gcloud container images list-tags gcr.io/[GCP_REPOSITORY_NAME]

And it basically gave what I want, but it is console and I need this data get programmatically on back-end side. Any ideas guys? Thanks in advance.

llompalles :

Currently there is no REST API for the Google Container Registry product but you can use the Registry name as an URL and run an HTTP request within your Java code against it:

curl -u "oauth2accesstoken:yourAccessToken" https://gcr.io/v2/yourProject/yourImage/tags/list 

You can get the accessToken with the command gcloud auth print-access-token. The recommend approach is that it belongs to a serviceAccount.

Although I am not sure if the Docker Registry HTTP API V2 is fully compatible with Google Container Registry, this specific method has worked for me.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=96931&siteId=1