Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for official Hub repository using v2 API #1253

Closed
CermakM opened this issue Nov 18, 2017 · 13 comments
Closed

Request for official Hub repository using v2 API #1253

CermakM opened this issue Nov 18, 2017 · 13 comments

Comments

@CermakM
Copy link

CermakM commented Nov 18, 2017

Hello, I am trying to query tags from official Docker Hub repository.
What I am doing is getting response to 'GET' request on:

https://hub.docker.com/v2/repositories/<namespace>/<repo>/tags/

Which works just fine for public user repos like fedora/apache.
My question is how to query official repo, ie. fedora

I tried
https://hub.docker.com/v2/repositories/fedora/tags/

or using _ and official as <namespace>

None of it works. I'd really appreciate your help.

Thank you,
Marek.

@thaJeztah
Copy link
Member

Docker Hub (hub.docker.com) is not the registry you're pulling from; Docker Hub is a web interface that allows you to browse the repositories/images that are available to pull from the Docker Registry

The registry itself is at https://registry-1.docker.io

Also see https://github.com/moby/moby/blob/master/contrib/download-frozen-image-v2.sh which is a shell script to download images without using docker, and may provide some insight as to what docker does when pulling an image

@CermakM
Copy link
Author

CermakM commented Nov 20, 2017

Hi, thank you for the answer. The link is useful, I'll check it out.
However, what I was doing up until now was just searching through the repositories and tags, so I basicly didn't need the registry itself, since I did not need to push/pull - that way I avoided the authentication. Querying the hub.docker.com/v2 was sufficient.
Are you telling me that* a)* this is not the right way to do it and b) there is no way to query an official repo like that? It works very well for the namespace/repository repos, tho.

@CermakM
Copy link
Author

CermakM commented Nov 20, 2017

By the way, using the registry... could you help me out with authentication to the registry? I kinda tried to follow the Docker guide I am still getting error: invalid token and message: "authentication required" ..
the ways I tried to query token:
https://auth.docker.io/token?serivce=registry.docker.io&scope=repository:fedora:pull for fedora repo
https://auth.docker.io/token?serivce=registry.docker.io&scope=registry:catalog:* and without :* at the end for registry catalog

I recieved the token in all cases, then I used it in the authorization header as Authorization: Bearer <token> for f.e https://registry-1.docker.io/v2/fedora/tags/list and https://registry-1.docker.io/v2/_catalog .. then I keep getting the error mentioned.
I appologize if this is kind of a stupid question, I am not very well-read in the topic of http requests etc. and I really appreciate your help.

@thaJeztah
Copy link
Member

I think there's two tokens in use; a short-lived token for pulling each image, and an authorisation header if to access private repositories. What exactly are you trying to do? I this to get a list of tags for a repository?

@CermakM
Copy link
Author

CermakM commented Nov 20, 2017

Yes, I know. At the moment I want to list tags and description of an official repository. It works for public repositories like fedora/apache, but not for the official ones, like fedora.

@thaJeztah
Copy link
Member

Does it work if you use library/fedora instead of just fedora? Even though official images show up as <somename>, the actual images are located in library/<somename>

@CermakM
Copy link
Author

CermakM commented Nov 20, 2017

Aaah there we go... Finally it works. If it is in docs and I missed it then well.. serves me right.. Otherwise this should really be stated somewhere.

Thank you very much.

@CermakM CermakM closed this as completed Jan 22, 2018
@tmc9031
Copy link

tmc9031 commented May 22, 2018

@CermakM how to get registry image tag, i also try "curl https://registry-1.docker.io/v2/_catalog"
but not work

@CermakM
Copy link
Author

CermakM commented May 22, 2018

@tmc9031 you need to provide authorization token to the curl as well, see the example from this conversation, official documentation or place a question on https://stackoverflow.com/. If you think there is an issue or bug in the implementation, open another issue ;).

@mlandisbqs
Copy link

I couldn't make this work and did not want to create an api token to query public information on available tags. I found this api URL works for GET or HEAD:

  // omit the tag if you want a list...
  await axios.head(`https://hub.docker.com/v2/repositories/library/node/tags/${nodeLtsVersion}`);

YMMV

@thaJeztah
Copy link
Member

@mlandisbqs that's the Docker Hub API (so specific to Docker Hub, not the registry); it's documented in the "reference" section of the documentation; https://docs.docker.com/reference/;

That endpoint is documented here;

https://docs.docker.com/docker-hub/api/latest/#tag/repositories/paths/~1v2~1namespaces~1%7Bnamespace%7D~1repositories~1%7Brepository%7D~1tags/get

@mlandisbqs
Copy link

@thaJeztah -- this was my experience based on that doco...

image

not sure what the special sauce is to make that work

@thaJeztah
Copy link
Member

library is the namespace for the official images; the _ is something the router uses for the GUI (honestly, don't know where that came from, but it was introduced a long time ago)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants