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.
2018-08-19
I have been stuck for days on this one and as I haven't found a complete answer with the why and how, I will post one for other people that stumble on the same problem and answers from above do not work.
These are the 3 crucial steps when running Jenkins inside docker:
/var/run/docker.sock
to the jenkins container in order to be able to use the docker from the host.sudo usermod -a -G docker jenkins
in order to add jenkins to the docker group. However, here you might run into a permission problem if the host docker and the container docker don't have the same group id so it is very important to adjust the container docker's gid to be the same as the host docker gidYou can do this as a part of a launch script or simply by using exec
and doing it manually: groupmod -g
.
Also, do not change permissions of the /var/run/docker.sock
to 777 or stuff like that because that is a big security risk, you are basically giving everyone permission to use docker on your machine
Hope this helps