我有下面的jenkinsfile,它给出了下面的错误。
node {
docker.withRegistry("https://001.dkr.ecr.eu-west-1.amazonaws.com/my-tooling") {
docker.image('my-tooling:deploy-agent_0.0.3')
.inside("-v /var/lib/jenkins/.ivy2:/home/jenkins/.ivy2", {
...
}错误
在尝试连接到unix :/ /var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/my-tooling:deploy-agent_0.0.3/json:拨号unix/var/run/docker.sock: connect:权限被拒绝时被拒绝了权限
我看到很多answers建议运行sudo usermod -aG docker $USER,但是由于我不是在本地运行这个,并且没有对vm的访问,因为它都是下面的代码,我如何将它添加到jenkinsfile中呢?
我试过像这样加进去,
node {
try {
stage('set permissions') {
sh "sudo usermod -aG docker jenkins"
//also tried "sudo chmod 777 /var/run/docker.sock"
}
} finally {
echo 'Unable to set permissions'
}
...
}但是我不能运行sudo因为我得到了错误..。
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
sudo: no tty present and no askpass program specified
script returned exit code 1发布于 2021-09-02 13:48:46
如果您到达堆栈溢出的问题是因为您从docker接收到此消息,但您没有使用jenkins,那么错误很可能是相同的:您的非特权用户不属于docker组。
你可以:
-a -G docker用户在用户所在的位置插入用户名。
您可以通过执行grep docker /etc/group来检查它是否成功,并看到如下所示:
docker:X:998:用户在一行中。
然后将用户组ID更改为docker:
newgrp码头最后,退出并再次登录。
https://stackoverflow.com/questions/69031524
复制相似问题