简体   繁体   English

Docker API 推送到私有注册表错误

[英]Docker API push to private registry error

I can't manage to push an image to a private registry using the docker API.我无法使用 docker API 将图像推送到私有注册表。 I have read everything I found everywhere and tried everything with no luck...我已经阅读了我在任何地方找到的所有内容并且尝试了所有内容但没有运气......

I tried :我试过 :

 curl -X POST -H "X-Registry-Auth:XXXXXXXXXXXXXXX" http://dockerapiurl:2375/images/registryurl/python/push?tag=6

OR或者

curl -X POST -H 'X-Registry-Auth:{"username": "xxxxxx","password": "xxxxx", "serveraddress": "xxxx.url.net", "auth": ""}' http://dockerapiurl:2375/images/registryurl/python/push?tag=6 curl -X POST -H 'X-Registry-Auth:{"username": "xxxxxx","password": "xxxxx", "serveraddress": "xxxx.url.net", "auth": ""}' http://dockerapiurl:2375/images/registryurl/python/push?tag=6

I always get the same error :我总是得到同样的错误:

{"errorDetail":{"message":"errors:\\ndenied: requested access to the resource is denied\\nunauthorized: authentication required\\n"},"error":"errors:\\ndenied: requested access to the resource is denied\\nunauthorized: authentication required\\n"} {"errorDetail":{"message":"errors:\\ndenied: 请求访问资源被拒绝\\nunauthorized: 需要身份验证\\n"},"error":"errors:\\ndenied: 请求访问资源被拒绝\\n未授权:需要身份验证\\n"}

If I use docker push in CLI mode everything works, what am I doing wrong?如果我在 CLI 模式下使用 docker push 一切正常,我做错了什么?

Thanks!!谢谢!!

it needs to be encoded in base 64, try this它需要以 base 64 编码,试试这个

XRA=`echo "{ \"username\": \"xxxxxx\", \"password\": \"xxxxxx\", \"email\": \"youmail@example.org\", \"serveraddress\": \"xxxxxx\" }" | base64 --wrap=0`
curl  -X POST  -d "" -H "X-Registry-Auth: $XRA" http://dockerapiurl:2375/images/registryurl/python/push?tag=6

end result should look like this最终结果应该是这样的

curl -X POST -d "" -H "X-Registry-Auth: eyAidXNlcm5hbWUiOiAieHh4eHh4IiwgInBhc3N3b3JkIjogInh4eHh4eCIsICJlbWFpbCI6ICJ5b3VtYWlsQGV4YW1wbGUub3JnIiB9Cg==" http://dockerapiurl:2375/images/registryurl/python/push?tag=6

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

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