Jenkins user using docker (inside docker container) -
i have dockerfile:
from jenkins:1.651.1 copy plugins.txt /usr/share/jenkins/plugins.txt run /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt user root run groupadd docker run usermod -a -g docker jenkins user jenkins
i add user jenkins
group docker
. when access container:
jenkins@bc145b8cfc1d:/$ docker ps cannot connect docker daemon. docker daemon running on host? jenkins@bc145b8cfc1d:/$ whoami jenkins
this content of /etc/group
on container
jenkins:x:1000: docker:x:1001:jenkins
my jenkins user in docker group
jenkins@bc145b8cfc1d:/$ groups jenkins jenkins : jenkins docker
what doing wrong? want use docker-commands jenkins user. i'm on amazon ec2 container service.
this how start container image:
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker:ro -v /lib64/libdevmapper.so.1.02:/usr/lib/x86_64-linux-gnu/libdevmapper.so.1.02 -v /lib64/libudev.so.0:/usr/lib/x86_64-linux-gnu/libudev.so.0 -p 8080:8080 --name jenkins -u jenkins --privileged=true -t -i my-jenkins:1.0
this 'solution' worked on ubuntu (not on centos). dockerfile
from jenkins:1.651.1 user root run apt-get update \ && apt-get install -y apt-transport-https ca-certificates \ && echo "deb https://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list \ && apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118e89f3a912897c070adbf76221572c52609d \ && apt-get update -y \ && apt-get install -y docker-engine run gpasswd -a jenkins docker user jenkins
run command:
docker run -d -it -v /var/run/docker.sock:/var/run/docker.sock test-jenkins
on ubuntu:
jenkins@c73c683b02d7:/$ whoami jenkins jenkins@c73c683b02d7:/$ docker ps container id image command created status ports names c73c683b02d7 test-jenkins "/bin/tini -- /usr/lo" 2 minutes ago 2 minutes 8080/tcp, 50000/tcp condescending_wing
it has gid
think: cat /etc/group
in container (on ubuntu , centos).
jenkins:x:1000: docker:x:999:jenkins
cat /etc/group
on ubuntu (also 999)
docker:x:999:ubuntu
cat /etc/group
on centos (different gid)
docker:x:983:centos
there solution this. needed ubuntu did not go further in this.
Comments
Post a Comment