Jenkins docker image provide the facility to run pipelines inside docker agent.
- Docker should be installed on host machine
-
Find out the docker group id on your host machine.
On a ubuntu machine you can find the docker group id like below.cut -d: -f3 < <(getent group docker)OR Run this command on any unix machine
cat /etc/group | grep dockerIt will give you output something like in below format.
docker:x:999:ubuntuIn this case
999is your docker group id. -
Run docker container like below.
ReplaceDOCKER_GROUP_IDwith value of docker group id from previous step.docker run --rm -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -e DOCKER_GID=DOCKER_GROUP_ID atifsaddique/jenkins