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

Errors with Docker Hub Registry #42

Open
so0k opened this issue Apr 18, 2017 · 1 comment
Open

Errors with Docker Hub Registry #42

so0k opened this issue Apr 18, 2017 · 1 comment

Comments

@so0k
Copy link

so0k commented Apr 18, 2017

This library doesn't seem to work with Docker Hub?
I also noticed the auth service for GitLab is very different from Docker Hub... so perhaps it's hard to support all the different ways auth services work?

The following doesn't seem to work:

docker-registry-show.py -v https://registry.hub.docker.com honestbee/fluentd-kubernetes logentries --username so0k --password **** --authorization-service https://auth.docker.io --api-version 2

Full log of error (after removing the v2 path of the auth.docker.io/v2/token call:

python docker-registry-show.py -v https://registry.hub.docker.com honestbee/fluentd-kubernetes logentries --username so0k --password **** --authorization-service https://auth.docker.io --api-version 2
DEBUG:docker_registry_client._BaseClient:Getting new token for scope: repository:honestbee/fluentd-kubernetes:*
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): auth.docker.io
DEBUG:requests.packages.urllib3.connectionpool:https://auth.docker.io:443 "GET /token?service=registry.hub.docker.com/v2&scope=repository:honestbee/fluentd-kubernetes:* HTTP/1.1" 200 None
DEBUG:docker_registry_client._BaseClient:GET /v2/honestbee/fluentd-kubernetes/manifests/logentries
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): registry.hub.docker.com
DEBUG:requests.packages.urllib3.connectionpool:https://registry.hub.docker.com:443 "GET /v2/honestbee/fluentd-kubernetes/manifests/logentries HTTP/1.1" 401 171
DEBUG:docker_registry_client._BaseClient:401 Unauthorized
ERROR:docker_registry_client._BaseClient:Error response: '{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"honestbee/fluentd-kubernetes","Action":"pull"}]}]}\n'
Traceback (most recent call last):
  File "docker-registry-show.py", line 138, in <module>
    cli.run()
  File "docker-registry-show.py", line 80, in run
    self.show_manifest(client, args.repository, args.ref)
  File "docker-registry-show.py", line 123, in show_manifest
    manifest, digest = repo.manifest(ref)
  File "/usr/local/lib/python3.6/site-packages/docker_registry_client/Repository.py", line 83, in manifest
    return self._client.get_manifest_and_digest(self.name, tag)
  File "/usr/local/lib/python3.6/site-packages/docker_registry_client/_BaseClient.py", line 186, in get_manifest_and_digest
    m = self.get_manifest(name, reference)
  File "/usr/local/lib/python3.6/site-packages/docker_registry_client/_BaseClient.py", line 193, in get_manifest
    schema=self.schema_1_signed,
  File "/usr/local/lib/python3.6/site-packages/docker_registry_client/_BaseClient.py", line 272, in _http_response
    response.raise_for_status()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 909, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://registry.hub.docker.com/v2/honestbee/fluentd-kubernetes/manifests/logentries

However, I'm able to get image digest without password using a script roughly like this:

import requests
auth_url = 'https://auth.docker.io/token'
auth_service = 'registry.docker.io'
reg_url = 'https://registry.hub.docker.com'

repo = "honestbee/fluentd-kubernetes"
ref = "logentries"
tag_url = {
 'reg_url': reg_url,
 'repo': repo,
 'ref': ref,
}
querystring = {
  'service': auth_service,
  'scope': 'repository:%s:pull' % repo,
}

auth_response = requests.request('GET',auth_url, params=querystring)
auth_data = auth_response.json()

reg_headers = {
  'accept': "application/vnd.docker.distribution.manifest.v2+json",
  'Authorization': 'Bearer %s' % auth_data['access_token']
}
get_manifests_v2 = "{reg_url}/v2/{repo}/manifests/{ref}".format(**tag_url)
reg_response = requests.request('GET', get_manifests_v2 , headers=reg_headers)
print(reg_response.json()['config']['digest'])
@djmattyg007
Copy link

Hello. Since this package seems to be abandoned, I forked it and implemented a significant number of improvements. This includes a big improvement to how the auth service works, so that it will hopefully support Docker Hub (though I haven't explicitly tested it).

I'd appreciate it if you could give it a go and let me know how you go:

https://github.com/djmattyg007/dreg-client

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

2 participants