Integrating the Git, Jenkins, Docker for automation

4 min readJun 20, 2020


In this task, I have integrated the Docker with Jenkins and Git for continuous integration.

Tasks :

  1. Create the docker image which contains the Jenkins and Git.
  2. Run the Jenkins image and pull the git repo from the GitHub as soon and the developer commits the file.
  3. By looking at the file whether HTML, PHP, etc Jenkins will run the respective language interpreter in the docker images.
  4. If for some reason the interpreter stops working or any error occurred the Jenkins will send the email to the developer to notify then.
  5. Once if for any reason the interpreter stops the job 4 will start the interpreter again of the respective language.

Creating the Docker File :

  • For creating the docker file save the file name with Dockerfile.
FROM centos

RUN yum install wget -y
RUN wget -O /etc/yum.repos.d/jenkins.repo
RUN rpm --import
RUN yum install sudo -y
RUN yum install git -y
RUN yum install java-11-openjdk.x86_64 -y
RUN yum install jenkins -y
RUN yum install python3 -y
RUN yum install curl -y
RUN echo -e "jenkins ALL=(ALL) NOPASSWD: ALL" >> etc/sudoers
CMD java -jar /usr/lib/jenkins/jenkins.war

Here’s the various keywords we used in it:

  • FROM: the base image to be used for the container.
  • RUN: execute these commands on the base image obtained.
  • CMD: to start a service when the container starts.
  • COPY: to copy the content inside the image.

Building the Dockerfile :

docker build -t jenkins:latest .
  • On successful build, you will see a screen like this.

Running the Jenkins Image :

docker run -it --privileged -p 9000:8080 -v /:/host jenkin:latest
  • Privileged: It is used for special access to be used later while playing with dockers.
  • -V : to mount the local files inside the containers.
  • Copy the marked password.
  • In administrator password paste the above copied password .

Now we will be moving on to our jobs:



  • This will be triggered as soon as Job1 completes and will deploy a container on the host system.


  • Job3 will be successfully built if the test fails so it can go to Job4 and mail to developer.


  • conatins


  • This is set for monitoring job to check every minute for the status of the container.
  • Thanks, hope you guys will like my article. if you have any suggestion or query will free to ask.

#Happylearning #keepsharing #devops #integration