Got permission denied while trying to connect to t

2020-01-27 00:01发布

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.

enter image description here

20条回答
混吃等死
2楼-- · 2020-01-27 00:35

If you may get errors like below,

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

or

level=error msg="failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: permission denied"

Just try to execute the following commands,

$ sudo su - jenkins
$ sudo usermod -a -G docker $USER
$ sudo chown jenkins:docker /var/run/docker.sock
查看更多
老娘就宠你
3楼-- · 2020-01-27 00:35

in my case it was just starting docker service :

sudo service docker start
查看更多
登录 后发表回答