navicore
navicore

Reputation: 2109

How do I list images and tags in google container registry

Looking for a way to use the gcloud commandline to get the tags of container engine registry images.

this command cloud docker search gcr.io/PROJECT/myimage returns NAME DESCRIPTION STARS OFFICIAL AUTOMATED PROJECT/myimage 0 but i want to see the tags used so far like the gcloud web console shows.

enter image description here

the machine I run this command on pulls images from docker hub, tags them, then pushes them to google container engine with gcloud docker push...

I suspect I may be asking how to make the local docker client do commands against both google repo and docker hub repo so I can get docker images listings

****** UPDATE: see https://stackoverflow.com/a/38061253/201911 for this capability in the latest release.

Upvotes: 13

Views: 17550

Answers (4)

Gaspar Chilingarov
Gaspar Chilingarov

Reputation: 89

Let me tell you hack to relieve your pain:

ZONE=eu
PROJECT_ID=testproject

PROJECT_URL=gs://${ZONE}.artifacts.${PROJECT_ID}.appspot.com/containers/repositories/library
    
# this generates images list
gsutil ls $PROJECT_URL | sed -e 's#/$##' -e 's#.*/##' 
    
IMAGE_URL=gs://${ZONE}.artifacts.${PROJECT_ID}.appspot.com/containers/repositories/library/${IMAGE_NAME}/

# this generates tags list for specified image
gsutil ls $IMAGE_URL | sed -n '/\/tag_/ { s#.*/tag_##p }'

This will serve you in most of the cases.

You will need read permissions to list files in that specific storage bucket in GCE.

Upvotes: 4

Keegan
Keegan

Reputation: 12207

First install the gcloud CLI (brew install google-cloud-sdk on MacOS). Then log in (gcloud auth login). Then use a command from below to list images/tags.

Listing images

CLOUDSDK_CORE_PROJECT=[PROJECT] gcloud container images list (e.g. CLOUDSDK_CORE_PROJECT=spiffe-io gcloud container images list)

Listing image tags

gcloud container images list-tags gcr.io/[PROJECT]/[IMAGE] (e.g. gcloud container images list-tags gcr.io/spiffe-io/spire-server)

There is currently no way to search for images across all projects.

See

Upvotes: 0

johnmcs
johnmcs

Reputation: 449

gcloud container images list-tags gcr.io/PROJECT/myimage https://cloud.google.com/sdk/gcloud/reference/container/images/list-tags

Upvotes: 17

Zachary Newman
Zachary Newman

Reputation: 21384

This is not currently possible with gcloud. gcloud docker is just a wrapper around the docker command line tool, which doesn't easily expose the information you'd like for remote repositories.

At some point in the future, gcloud may support this feature.

Upvotes: 0

Related Questions