簡體   English   中英

使用Docker注冊表API進行身份驗證

[英]Authenticate with Docker registry API

我正在嘗試通過https://registry-1.docker.io/v1/上的Docker注冊表API進行身份驗證

我正在嘗試打電話

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。 然后,我將所有這些信息提供給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'
}

您共享的文檔中有以下一行:

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

在集線器上進行身份驗證時,需要發送“ X-Docker-Token:true”,然后在標頭中收到“ X-Docker-Token”。 將其作為“授權:”發送到“ X-Docker-Endpoints”中的注冊表,您就可以進入。

祝好運! :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM