简体   繁体   English

使用Docker注册表API进行身份验证

[英]Authenticate with Docker registry API

I am trying to auth with the Docker registry API at https://registry-1.docker.io/v1/ 我正在尝试通过https://registry-1.docker.io/v1/上的Docker注册表API进行身份验证

I am trying to do calls like 我正在尝试打电话

https://registry-1.docker.io/v1/repositories/_/ubuntu/tags 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. 遵循这些准则,我首先向HUB身份验证并请求令牌。 This suceeds and I get the token and a cookie from the HUB. 这样就可以了,我从HUB获得了令牌和cookie。 Then I supply all this towards the Registry API as follows: 然后,我将所有这些信息提供给Registry API,如下所示:

{ 
  '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. 在集线器上进行身份验证时,需要发送“ X-Docker-Token:true”,然后在标头中收到“ X-Docker-Token”。 Send this out as 'Authorization:' to the registry in 'X-Docker-Endpoints' and you're in. 将其作为“授权:”发送到“ X-Docker-Endpoints”中的注册表,您就可以进入。

Good luck! 祝好运! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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