Jenkins and Docker | jenkins pipeline docker build
Intheillustrationbelow,ihave createdadockerimageofjenkinswithdockerinstalled.HereistheDockerfile:FROMjenkins/jenkins:ltsUSERrootRUNapt-getupdate&&apt-get-yinstallapt-transport-httpsca-certificatescurlgnupg2software-properties-common&&curl-fsSLhttps://download.docker.com/linux/$(.[1]/etc/os-release;echo"$ID")/gpg>/tmp/dkey;apt-keyadd/tmp/dkey&&add-apt-repository"deb[arch=amd64]https://download.docker.com/linux/$(.[2]/etc/os-release;echo"$ID")$(lsb_release-cs)stable"...
In the illustration below, i have created a docker image of jenkins with docker installed.
Here is the Dockerfile:
FROM jenkins/jenkins:lts USER root RUN apt-get update && apt-get -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common && curl -fsSL https://download.docker.com/linux/$(.[1] /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(.[2] /etc/os-release; echo "$ID") $(lsb_release -cs) stable" && apt-get update && apt-get -y install docker-ce RUN apt-get install -y docker-ce RUN usermod -a -G docker jenkins USER jenkinsThis Dockerfile is built from jenkins official image, install docker and give access to user jenkins build dockers.
Note: You can build this image, but is already in dockerhub gustavoapolinario/jenkins-docker[3].
...