我在localhost中有我的docker-registry,我可以用命令拉/推:docker push localhost:5000 / someimage
如何使用docker push username @ password:localhost:5000 / someimage等命令推送它?
最佳答案
这个解决方案对我有用:
首先,我创建了一个文件夹注册表,我想在其中工作:
首先,我创建了一个文件夹注册表,我想在其中工作:
$mkdir registry
$cd registry/
现在我创建了我将保存凭据的文件夹
$mkdir auth
现在我将在docker容器的帮助下创建一个htpasswd文件.
此htpasswd文件将包含我的凭据和加密的passwd.
$docker run --entrypoint htpasswd registry:2 -Bbn myuser mypassword > auth/htpasswd
核实
$cat auth/htpasswd
myuser:$2y$05$8IpPEG94/u.gX4Hn9zDU3.6vru2rHJSehPEZfD1yyxHu.ABc2QhSa
证书很好.现在我必须将我的凭据添加到我的注册表中.在这里,我将我的auth目录挂载到我的容器中:
docker run -d -p 5000:5000 --restart=always --name registry_private -v `pwd`/auth:/auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" registry:2
测试:
$docker push localhost:5000/busyBox
The push refers to a repository [localhost:5000/busyBox]
8ac8bfaff55a: Image push Failed
unauthorized: authentication required
认证
$docker login localhost:5000
Username (): myuser
Password:
Login Succeeded
重试推送
$docker push localhost:5000/busyBox
The push refers to a repository [localhost:5000/busyBox]
8ac8bfaff55a: Pushed
latest: digest: sha256:1359608115b94599e5641638bac5aef1ddfaa79bb96057ebf41ebc8d33acf8a7 size: 527
凭据保存在〜/ .docker / config.json中:
cat ~/.docker/config.json
{
"auths": {
"localhost:5000": {
"auth": "bXl1c2VyOm15cGFzc3dvcmQ="
}
}
不要忘记在使用凭据时建议使用https.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。