quay/mirror-registry

Bearer Token

yigitpolat opened this issue · 7 comments

I execute below command to see which images exists in the registry but receving an error message also posted as an output of the command.

$ curl -u <username>:<password> -k https://<hostname>:8443/v2/_catalog
{"error": "Invalid bearer token format"}

Is there anyway to retrieve the token, otherwise is there any other way of listing images?
Thank you in advance

v2/_catalog endpoint is a Docker v2 endpoint and you need a JWT bearer token to use it. To get one:

curl --user username:password -k "https://QUAY_HOSTNAME/v2/auth?service=QUAY_HOSTNAME?scope=repository:namespace/repository:pull"
curl -H "Authorization: Bearer JWT_TOKEN_FROM_PREVIOUS_CALL" -k https://QUAY_HOSTNAME/v2/_catalog

You'll then get a list of all namespaces and repos you have access to. The _catalog endpoint is very heavy on the db, which is why it's behind auth. An alternative approach is to use Quay's v1 API to list repos inside namespaces:

https://docs.quay.io/api/swagger/#!/repository/listRepos

HTH!

Thanks !

@ibazulic a topic just out of curiosity.
Do you have a content that I can read more about v1 vs v2 api endpoints.
To illustrate, when you say Quay's v1 API, I assume it is different then Docker v1.
And also when I looked for Quay v2 API, I couldnt find any information. So I assume Docker v2 and Quay v2 are in different contexts.
I hope I could be clear on my confusion.

@yigitpolat Quay has its own v1 API which is described on

https://docs.quay.io/api/swagger

This is not the same as Docker's v1 API which no one uses anymore. There is no Quay v2 API, but Quay fully supports Docker's v2 api which can be found here:

https://docs.docker.com/registry/spec/api/

Does that answer your question?

@ibazulic it was extremely fast response. Thanks for that.
It clarifies most of the thing. Just one more point and it will be clear.
Is quay top of Docker Registry (https://docs.docker.com/registry/), so that it supports Docker's v2?

I guess I am mistaking the concepts, but I should have mean Docker Protocol instead of Docker Registry.