Jenkins 사용자가 Docker unix 소켓에 액세스 할 수있는 권한이없는 이유는 무엇입니까?

Jenkins 작업이 Docker 명령을 실행할 수 있다고 생각하는 jenkins사용자를 docker그룹에 추가했습니다 . jenkins사용자로 전환하면 (수동으로) 작동하는지 확인할 수 있습니다.

ubuntu@hostname:~$ ps aux | grep java
jenkins   2210  9.5  7.5 1950316 292896 ?      Sl   00:01   1:00 /usr/bin/java -jar /data/jenkins/jenkins-1.586.war --httpPort=8080 -Xloggc:/var/log/jenkins/gc.log
ubuntu@hostname:~$ getent group docker
docker:x:999:jenkins
ubuntu@hostname:~$ ls -la /var/run/docker.*
-rw-r--r-- 1 root root   4 Oct 23 18:32 /var/run/docker.pid
srw-rw---- 1 root docker 0 Oct 23 18:32 /var/run/docker.sock
ubuntu@hostname:~$ sudo su -s /bin/bash jenkins
jenkins@hostname:/home/ubuntu$ docker ps
CONTAINER ID        IMAGE                      COMMAND                CREATED             STATUS              PORTS                     NAMES

그러나 Jenkins 빌드 / 작업 중에는 권한이 없습니다.

# Job log
Started by user Matt Wright
Building on master in workspace /data/jenkins/jobs/docker-base-images-build/workspace
[ssh-agent] Using credentials CI-jenkins
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Java/JNR ssh-agent
[ssh-agent] Started.
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@github.com:<redacted>/docker-base-images.git # timeout=10
Fetching upstream changes from git@github.com:<redacted>/docker-base-images.git
 > git --version # timeout=10
using GIT_SSH to set credentials
 > git fetch --tags --progress git@github.com:<redacted>/docker-base-images.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 83c4463e7195b412a3a803dd7338210c1a772f55 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 83c4463e7195b412a3a803dd7338210c1a772f55
 > git rev-list 83c4463e7195b412a3a803dd7338210c1a772f55 # timeout=10
[workspace] $ /bin/sh -xe /tmp/hudson5606381166745886966.sh
+ ./build.sh
Sending build context to Docker daemon
2014/10/24 16:14:18 Post http:///var/run/docker.sock/v1.15/build?rm=1&t=<redacted>%2Fpython%3A3.4: dial unix /var/run/docker.sock: permission denied
Build step 'Execute shell' marked build as failure
[ssh-agent] Stopped.
Notifying upstream projects of job completion
Finished: FAILURE

Docker 1.3.0 및 Ubuntu 14.04.1과 함께 제공됩니다. 단서가 있습니까?



답변

도커 유닉스 소켓에 jenkins 그룹 권한을 부여하면 문제가 해결된다고 생각합니다. 이 줄을 추가하여 구성 파일에서 docker daemon 시작 옵션을 구성하여 수정할 수 있습니다

DOCKER_OPTS=' -G jenkins'

우분투 /etc/default/docker에는 도커 구성 파일이 있습니다.


답변

groupsjenkins를 사용하여 명령을 실행하십시오 . 당신은 볼 수 있나요 docker그룹을? 그렇지 않은 경우 해당 Jenkins 슬레이브를 재부팅하십시오. 또는 Jenkins slave.jar 프로세스를 종료하십시오. ps aux | grep jenkins