We want to query gcr.io using Python. However, as of this writing, any of the below is not possible:
client.images.list() only lists local imagesdocker registry in desktop is experimental and not available for querying GCRThe only "hack" is to execute gcloud container images list (and list-tags) xxx in a subprocess and parse to extract the info you need.
We could too parse the HTML response from the GCP console (browser) but that would be more work.
Any other idea on how to easily list GCR images in Python ?
And to Docker and Googlers, any plan on extending your Python library to interact with remote registries, *.gcr.io in particular ?
Google Container Registry implements the same Docker HTTP API as any other Docker registry.
First, get an access token for your account, either with gcloud auth print-access-token or one of these alternatives.
Then, use Docker's "Listing Repositories" endpoint of the HTTP API:
>>> import requests
>>> access_token = ...
>>> resp = requests.get('https://gcr.io/v2/_catalog', auth=('_token', access_token))
>>> resp.json()
{
"repositories": [
<name>,
...
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With