-1

I am looking to fetch images that are available gcr using a gcloud API.

I have tried GET https://compute.googleapis.com/compute/v1/projects/myproject/global/images/myimage but I wont get anything back.

If I remove remove /myimage from the call above, I get some images back but not the images on the GCR as compute returns GCE images.

I found https://gcr.io/v2/myproject/myimage/tags/list which does return the data I expect. But using this is not an option for me.

Is there an actual google API that returns something similar as the SDK gcloud container images describe gcr.io/myproject/myimage or as https://gcr.io/v2/myproject/myimage/tags/list ?

e.f.a.
  • 323
  • 1
  • 4
  • 12
  • `https://compute.googleapis.com/compute/v1/projects/myproject/global/images` is for GCE images https://cloud.google.com/compute/docs/images, NOT for container images – Puteri Sep 10 '22 at 00:58

1 Answers1

3

Google Container Registry (GCR) implements the Docker Registry HTTP API V2 for image management.

See Google's docs for Container Registry: Docker Registry API.

You can confirm this to yourself by running any of the gcloud container images sub-commands with the --log-http flag to show the underlying REST API calls e.g.

gcloud container images list --log-http

You may find it useful to use commands like the above as an exemplar for using the API w/ GCR

It is useful that Google chose to implement Docker's API because it means that you can use e.g. docker, podman and any other existing tools that talk to the Docker API to interact with GCR.

The downside is that the API is not a Google API and so requires understanding Docker's methodology. In my experience, the APIs' a little gnarly.

DazWilkin
  • 32,823
  • 5
  • 47
  • 88
  • 1
    A long time ago (!) I wrote [Adventures w/ Container manifests](https://medium.com/google-cloud/adventures-w-docker-manifests-78f255d662ff) which documents some of these methods with GCR. It's old but it may provide some help. – DazWilkin Sep 09 '22 at 23:19