Docker:尝试连接到unix:///var/run/docker.sock上的Docker守护进程套接字时,获得的权限被拒绝 [英] Docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

查看:1839
本文介绍了Docker:尝试连接到unix:///var/run/docker.sock上的Docker守护进程套接字时,获得的权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的新手.我只是尝试在Jenkins的本地计算机(Ubuntu 16.04)中使用docker.

I am new to docker. I just tried to use docker in my local machine(Ubuntu 16.04) with Jenkins.

我使用以下管道脚本配置了新作业.

I configured a new job with below pipeline script.

node {
    stage('Build') {
      docker.image('maven:3.3.3').inside {
        sh 'mvn --version'
      }
    }
}

但是失败,并出现以下错误.

But it fails with below error.

推荐答案

用户jenkins需要添加到组docker中:

sudo usermod -a -G docker jenkins

然后重新启动Jenkins.

Then restart Jenkins.

如果由于收到来自docker的此消息而遇到堆栈溢出的问题,但您没有使用jenkins,则错误很可能是相同的:您的非特权用户不属于docker组.

If you arrive to this question of stack overflow because you receive this message from docker, but you don't use jenkins, most probably the error is the same: your unprivileged user does not belong to the docker group.

您可以这样做:

sudo usermod -a -G docker alice

或您的用户名是什么.

您可以在执行grep docker /etc/group的最后检查它,并看到类似以下内容的内容:

You can check it at the end doing grep docker /etc/group and see something like this:

docker:x:998:alice

其中一行.

然后将您的用户组ID更改为docker:

Then change your users group ID to docker:

newgrp docker

这篇关于Docker:尝试连接到unix:///var/run/docker.sock上的Docker守护进程套接字时,获得的权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆