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



我正在尝试使用Docker注册表API进行身份验证,位于https://registry-1.docker.io/v1/

我试着打这样的电话

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

然而,我不断得到如下回复:

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"}

我已经阅读了文档和论坛中的所有可用指南。

根据这些指导原则,我首先向HUB授权并请求令牌。这成功了,我从HUB获得了代币和cookie。然后我将所有这些提供给注册表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'
}

您共享的文档中只有一行:

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

当您在集线器上进行身份验证时,您需要发送"X-Docker-Token:true",然后在标头中收到一个"X-Docker-Token"。将其作为"授权:"发送到"X-Docker-Endpoints"中的注册表,您就进入了。

祝你好运!:)

最新更新