Automated Web Development

In this task we are going to create a setup integrating jenkins, docker, git and GitHub so that when a developer push a code to GitHub the code will be deployed to server running in a container and if the code has some error we have to send email notification regarding that. Here we will see how to make a docker image which hosts jenkins inside it. Then we will create a build job chain.


  1. Create an image using CentOS wherein the Jenkins is pre-installed. When this image run the user will get the Jenkins running.

JOB Description:

  1. JOB1: Pull the GitHub repo automatically when some developer commits.
  2. JOB2: By looking at the code or program file, jenkins should automatically start the respective language interpreter install image container to deploy code code ( eg. If code is of PHP, then jenkins should start the container that has PHP already installed)
  3. JOB3: Test your application if it is working or not.
  4. JOB4: If application is not working, then send email to developer with error message and if it is running file send a success message.
  5. JOB5: To monitor the container where the application is hosted, fails due to any reason then this job will automatically start the container again.

Required Tool :

Install docker in Redhat(linux).

Install jenkins in Redhat(linux) .

Install Git in Redhat(linux) .

Install Python in Redhat(linux) .

Docker -

Step1: Create container image that’s has Jenkin installed using dockerfile.

To create the image that start the jenkins when we run the image I have use the Centos docker image and install the jenkins over it .

We use some keywords like :

  1. FROM : To select the pre-installed image wherein on top of it you will customize it for your own use.
  2. RUN: To run command inside the container while creating it. For example: If you want wget to be installed in your custom image you can do it using RUN yum install wget -y or RUN sudo apt-get install wget for Ubuntu or Debian version.
  3. CMD : To run any command on booting.
  4. EXPOSE : To expose the port you want to. Here we can only give the one port number that will be exposed to the outer world. So if you want to expose any container it’s better you give it at run time.

Step2: Build Dockerfile.

To build Dockerfile-

docker build -t img-name:version <path of image>

when Dockerfile is successfully build , it will create a container image

Step3: Run the container using the dockerfile we created.

For creating the container using the created Dockerfile

docker run -it — privileged -p -v /:/host — name jenkins2 jenkins:v1

"-P" means it will go inside the image's configuration and will look for which port is exposed. It will then allocate one random port and link that with that exposed port.

"-v /:/host" this command will attach our base os absolute directory to the container.

" --privileged" this will allow our docker to go inside base os and from inside container we will be able to run any commands in base os.

Now Here we will find the initial password of jenkins. This is needed to unlock Jenkins for the 1st time.

Type the IP address and login to jenkins.

JOB Description

Job1 : Pull the Github repo automatically when some developers push repo to Github.

Job2: Configuration.

Here we have compatibility for python, html & php. If you want some more language to be handled then you can add it. One more thing here we need to take care of is we need to make containers for these language interpreter also.

Now, this is for Email Configuration-

Job3 : Here again use the previous trigger. This code will check if our php code is working fine or not.

If our php code has any error then it will send notification to the developer.

Job4: This job will keep on monitoring if docker container is running or not.

Job5: Now here is the view of build pipeline.

Go to jenkins dashboard after installing plugin and restarting jenkins where it will show a + symbol.

Then give any name for the list. Then select the Build Pipeline option. Then click ok.

You will see a beautiful build pipeline of job chain job1 , job2 , job3 and job4 ready which is interactive and even more important is its fully automatic with mail notification and monitoring system.

Thankyou for Reading !