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 images docker registry
in desktop is experimental and not available for querying GCR The 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>,
...
]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.