问题描述
我有一个专用的docker仓库,用于存储构建映像。
我确实复制了我的注册表证书并更新了/ etc / hosts文件以从本地计算机上对注册表进行身份验证。
I have a private docker repository where i store my build images.I did copy my registry certificates and updated my /etc/hosts file to authenticate registry from my local machine.
我可以使用<$ c登录到注册表$ c>'sudo docker login -u xxx -p xxx Registry-name:port'
但是当我尝试从gitlab-ci阶段,它失败并出现以下错误:
But when i try same docker login command from gitlab-ci stage, it is failing with this error:
这就是我要实现的目标。
This is how i'm trying to achieve this.
ssh manohara@${DEPLOY_SERVER_IP} "sudo docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}"
我还尝试在/ etc / sudoers底部添加此gitlab-runner ALL =(ALL)NOPASSWD:ALL
文件,但是没有运气
我要去哪里了?
I also tried adding this gitlab-runner ALL=(ALL) NOPASSWD: ALL
at the bottom of /etc/sudoers file, but no luckWhere am i going wrong?
推荐答案
According to this Source you can use
ssh -t remotehost "sudo ./binary"
-t分配一个伪tty。
The -t allocates a pseudo-tty.
或在您的示例中:
ssh -t manohara@${DEPLOY_SERVER_IP} "sudo docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}"
这篇关于在gitlab-ci.yml中使用sudo时如何避免密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!