Docker远程API从Docker中心私有registry中拉出

我试图从托pipe在Docker中心https://registry.hub.docker.com/u/myname/myapp中的私有存储库中使用docker远程API来拖动docker镜像。 文档不清楚如何在POST请求中指定身份validation凭证

curl -XPOST -H "X-Registy-Auth: base64_encoded_authconfig_object" "http://localhost:4243/images/create?fromImage=myname/myapp" 

这也没有详细说明如何生成authconfig。

这讲到发送一个像这样的结构的基础64编码json:

 { "index_url": { "username": "string", "password": "string", "email": "string", "serveraddress": "string" } } 

但是不解释什么是index_url和serveraddress。 他们是吗?

 index_url = https://registry.hub.docker.com/u/myname/myapp serveraddress = https://registry.hub.docker.com 

上面的configuration给我404,可能注册中心私人回购没有被识别。

我也试过base 64编码我的〜/ .dockercfg的内容

 { "https://index.docker.io/v1/": { "auth":"xxxxxxxxxxxxxxxxxxx==", "email":"myname@myemail.com" } } 

你能告诉我如何生成base64编码authconfig对象,并获得上述curl命令的工作。

提前致谢

docker版本

 Client version: 0.11.1 Client API version: 1.11 Go version (client): go1.2.1 Git commit (client): fb99f99 Server version: 0.11.1 Server API version: 1.11 Git commit (server): fb99f99 Go version (server): go1.2.1 

我遇到过同样的问题。

以下是您应该用来传递凭据的“原始” AuthConfig对象:

 {
   “用户名”:“your_registry_username_or_email”
   “密码”:”*****”,
   “auth”:“”,//留空
   “电子邮件”: “your@email.tld”
 }

然后您必须使用Base64 “编码”它。

你没有告诉你正在使用什么语言,但如果需要的话, 这个真棒网站将让你在一个单一的点击编码你的对象。 或者,从一个shell:

 echo '{"username":"username","password":"*****", "auth":"","email":"your@email.tld"}' | base64 

然后,只需将编码值传递给标题:

 X-Registry-Auth: eyJ1c2VybmFtZSI6InlvdXJfcmVnaXN0cnlfdXNlcm5hbWVfb3JfZW1haWwiLCJwYXNzd29yZCI6IioqKioqIiwiYXV0aCI6IiIsImVtYWlsIjoieW91ckBlbWFpbC50bGQifQ== 

这是一个使用curl

  • 在r.getitlive.io上提供的registry
  • 在“192.168.60.10:8888”处监听的docker守护进程:
 curl -X POST -d“”\
   -H“X-Registry-Auth:eyJ1c2VybmFtZSI6InlvdXJfcmVnaXN0cnlfdXNlcm5hbWVfb3JfZW1haWwiLCJwYXNzd29yZCI6IioqKioqIiwiYXV0aCI6IiIsImVtYWlsIjoieW91ckBlbWFpbC50bGQifQ ==”\“
   'http://192.168.60.11:8888/images/create?fromImage=r.getitlive.io/cool/repo&tag=latest'

注意:通过将远程registry端点/ URL放置在serveraddress对象的serveraddress字段中,我无法使其工作。 这就是为什么我fromImage=registry主机添加到fromImage=参数。

从这个合并的docker pull请求中 ,似乎X-Registry-Auth头应该是一个base-64编码的jsonstring

 { 'username': string, 'password': string, 'email': string, 'serverddress' : string } 

另一个参考链接