Docker remote api pull from Docker hub private registry

瘦欲@ 提交于 2019-11-30 09:05:27

I had the same issue.

Here's the "raw" AuthConfig object that you should use to pass the credentials:

{
  "username":"your_registry_username_or_email",
  "password":"*****",
  "auth":"",    // leave empty
  "email":"your@email.tld"
}

You then have to "encode" it using Base64.

You didn't tell what language you're using, but if needed, this awesome site will let you encode your object in one click. Or, from a shell:

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


Then, just pass the encoded value to the header:

X-Registry-Auth: eyJ1c2VybmFtZSI6InlvdXJfcmVnaXN0cnlfdXNlcm5hbWVfb3JfZW1haWwiLCJwYXNzd29yZCI6IioqKioqIiwiYXV0aCI6IiIsImVtYWlsIjoieW91ckBlbWFpbC50bGQifQ==

Here's a working example using curl and

  • a registry available at r.getitlive.io
  • a docker daemon listening at '192.168.60.10:8888' :
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'

Note : I couldn't make it work (yet) by putting the remote registry endpoint/URL in the serveraddress field of the AuthConfig object. That's why I'm adding the registry host to the fromImage=parameter.

From this merged docker pull request, it seems that X-Registry-Auth header should be a base-64 encoded json string of the form

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

another reference link

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!