{GitHub + Docker + Jenkins} MlOps & DevOps Task2

5 min readJul 21, 2020


This article is a simple integration of GitHub, Jenkins and Docker to automate the process of deploying a website by creating custom Docker images using Dockerfile.


Pull the GitHub repository automatically when some developers push the repository to GitHub.


By looking at the code or program file, Jenkins should automatically start the respective language interpreter install image container to deploy code ( eg. If code is of HTML, then Jenkins should start the container that has HTML already installed ).


Test your SYSTEM if it is working or not.


If the SYSTEM is not working, then send an email to the developer with error messages.


Create one extra job for monitoring purpose: If a container, where the SYSTEM is running, fails due to any reason then this job should automatically start the container again.

Let’s start with the workflow for this task:

To create one image containing various features installed like automatically start the Jenkins, Load the system which can automatically select an interpreter for the above task. We have to manually create one Dockerfile to launch the container with our own image.

Dockerfile created successfully.

Now, We will create an image by using the above Dockerfile named as “mkos:m1”

cmd>> docker build -t mkos:m1 .

Now, let’s create the container to run the Jenkins with docker image which we have created just now. Run the below command for the same:

docker run -it --name mk --privileged -p 2514:8080 -v /:/host mkos:m1

privileged is used for running docker in the base OS and -p is to expose the container port to the base OS, hence giving access to the user to connect. Now the port number 2514 is mounted onto the internal Jenkins port 8080.

After completing the Jenkins installation with the required plugins(GitHub, SSH, E-mail etc. ) we are ready to proceed further :

JOB #1 :

After doing the successful setup of Jenkins in your local host now create a new item to start our task, In the task as mentioned at the start, We have to build the first Job which can automatically pull repo from your GitHub Repo just by giving some triggers.

It is clearly showing in the above images, We have to copy the HTML file which we cant to display as output bypassing to job2 for running on the web server. You can find shell command here.

sudo cp {file name} {dir}

JOB#2 :

Let’s move towards the Job2 and which is the tough part of this task. Here you have to use some logic part because this job should automatically detect your code and launch the respective code interpreter and launch the container for the same.

In my case, I’m using an HTML file so it should start httpd image container to run HTML file on the web server. We will use here httpd image here which is officially available online.

docker pull httpd
systemctl start httpd
later i changed port no to 8950 as 2514 is being used by Jenkins.


This is just the simple testing job that checks the other jobs that are they working fine or not.

HTTP code for the successful execution of server or file execution gives status as 200 and for failure is 500, Hence we used above http_code. Also, we added exit 0 or 1 to shown failure or success output for Jenkins output.

JOB#4 :

Here come one more important part and interesting one in our task, That when you test the jobs running in the system and if build failure occurs than How developer will get to know about this situation?

For this, There should be some notification system for the automation task we made.

So, Here Job4 will directly send a build failure message to the developer if system failure occurs.

JOB#5 :

This job will work in monitor the system, Like if the system fails then it will automatically start a new container to don’t make a failure in the project.

We will use SCM polling for this, * here represents 1min.

We will add some commands which will be used for launching a new container after a system failure.

Here comes the full setup :

Now, Lets Build pipeline for monitoring the jobs, Configure and set the first job as DevOps-Job-1 which is my job1 for this task.

So, Here is the beautiful output for the above task.

Thanks for reading…

LinkedIn profile: https://www.linkedin.com/in/mayank-varshney-62744a163




I am a forward-thinking individual with exceptional skills in problem-solving, adaptive thinking, automation, and development.