简体   繁体   中英

Authenticate with Docker registry API

I am trying to auth with the Docker registry API at https://registry-1.docker.io/v1/

I am trying to do calls like

https://registry-1.docker.io/v1/repositories/_/ubuntu/tags

However I keep getting a reply as below:

401
{ server: 'gunicorn/18.0',
  date: 'Sun, 01 Mar 2015 12:19:13 GMT',
  connection: 'close',
  expires: '-1',
  'content-type': 'application/json',
  'www-authenticate': 'Token',
  pragma: 'no-cache',
  'cache-control': 'no-cache',
  'content-length': '35',
  'x-docker-registry-version': '0.8.2',
  'x-docker-registry-config': 'prod',
  'strict-transport-security': 'max-age=31536000' }
{"error": "Requires authorization"}

I have read all available guidelines as in the docs and forums .

Following those guidelines I first auth towards the HUB and request a Token. This suceeds and I get the token and a cookie from the HUB. Then I supply all this towards the Registry API as follows:

{ 
  'set-cookie': 'csrftoken=VfHe6...; Expires=Sun, 28 Feb 2016 12:19:13 GMT; Max-Age=31449600; Path=/; Secure',
  'www-authenticate': 'Token signature=VfHe6...,repository="ubuntu",access=read',
  'x-docker-token': 'Token signature=VfHe6...,repository="ubuntu",access=read',
  Authenticate: 'Token signature=VfHe6...,repository="ubuntu",access=read',
  Authorization: 'Token signature=VfHe6...,repository="ubuntu",access=read'
}

There is this single line in the docs you shared:

Token is only returned when the X-Docker-Token header is sent with request.

You need to send 'X-Docker-Token: true' when you authenticate on the hub, then you receive in the header a 'X-Docker-Token' back. Send this out as 'Authorization:' to the registry in 'X-Docker-Endpoints' and you're in.

Good luck! :)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM