Method 1: Assuming your docker
command has the gcr credentials, you can try to pull the image like docker pull gcr.io/foo/image:tag
. This would be slow, but it's a guaranteed way.
Method 2: Assuming gcloud
is present in your environment, you could run gcloud container images list-tags [- -format=json] gcr.io/foo/image
and see if the output has the tag
you want.
Method 3: If these two solutions aren't good enough for you, you can learn how to use your Google Cloud Service Account as a docker username/password here, and then use the Docker Registry v2 API to List Image Tags or just directly Query the image manifest for pulling the image with the tag
.
For example, if you had an gcr.io/foo/alpine:v1
image, to test this using cURL and a temporary access_token
(obtained via gcloud), you could run:
TOKEN="$(gcloud config config-helper --format 'value(credential.access_token)')"
curl -H "Authorization: Bearer $TOKEN" \
https://gcr.io/v2/foo/alpine/manifests/v1
and if you get an 200 OK response, it means that tag exists.