Jenkins on Docker

I’ve been doing a lot of research on how we could get Jenkins to work on Docker. There are people out there who have already done it and I have surely been able to learn from them.

I would like to summarize what I have learn from different sites and what I have figured out in the last 2 months. I have documented quite a bit of stuff at work but I am going to document some on my own site using my own time for the community.

Let’s see when I can find the time to do it…  

Executing Dockerfile

I was under an impression that you can create Dockerfile only with the name “Dockerfile” but you can use -f option to give a different file name.

docker build -f jenkins-master.dockerfile -t jenkins-master:2.138.1 .

This will generate jenkins-master:2.138.1 image locally based on the Dockerfile “jenkins-master.dockerfile”. Content of the Dockerfile is shown below.

FROM jenkins/jenkins:lts
USER root
RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/*