Jenkins is the way to automate, create, and execute

Deploy Jenkins on Docker Container

Submitted By Jenkins User Anuja Kumari
Automate Jenkins inside a docker container with the help of Dockerfile and then create and execute different Jenkins jobs running inside a container.
Organization: LinuxWorld informatics Pvt Ltd, <>
Project Website: <>
Industries: Information Technology
Programming Languages: Python
Platform: : Docker or Kubernetes, Linux, Windows
Version Control System: GitHub
Build Tools: Jenkins
Community Support: websites & blogs

As soon as a Docker container is launched, it automatically starts and executes Jenkins jobs.

Background: I wanted to be able to look at the code or program file in GitHub repo and have Jenkins automatically start the respective language interpreter installed in the container to deploy code. For example, if the code is of PHP, Jenkins should start the container that has PHP already installed. And I wanted that as soon as I launch a container it will automatically start the Jenkins service.

Goals: Integrating Jenkins, Red Hat Enterprise Linux (RHEL), GitHub, and Docker so that as soon as we launch the Docker container, it will automatically start the Jenkins service.

Solution & Results: I created an image for Jenkins and launched a container using that image. I then created jobs using the build pipeline plugin. Steps that I used to solve this challenge include:

  • Step 1. I created a container image that has Jenkins installed using Dockerfile.
  • Step 2. When I launch this image, it automatically starts the Jenkins service in the container.
  • Step 3: Then I created a job chain of job1, job2, job3, and job4 using the build pipeline plugin in Jenkins.
  • Step 4. Create #Job1: Pull the GitHub repo automatically when some developers push the repo to Github.
  • Step 5. Create #Job2: By looking at the code or program file, Jenkins automatically starts the respective language interpreter install image container to deploy the code (e.g., if the code is of PHP, then Jenkins starts the container that has PHP already installed).
  • Step 6. Create #Job3: Then I created job3 to test whether my app is working or not.
  • Step 7. Create #Job4: If the app is not working, then send an email to the developer with error messages
  • Step 8. Create #Job5 for monitoring: If the container where the app is running fails due to any reason, then this job will automatically start the container again.
Using Jenkins in my project reduces the time I need to spend managing it.
profile picture
Anuja Kumari, Student, Sandip Institute of Technology & Research Centre

Key capabilities used included:

  • Build pipeline plugin: This plugin handles the creation of multiple automatic and/or manually triggered downstream build steps on the same project.
  • GitHub plugin: This plugin allows us to schedule your build and facilitates the easy transfer of data from the GitHub repository to the Jenkins machine. Moreover, it also triggers each build automatically after each commit.

Results are standard but much appreciated:

  • Build times become faster
  • Time spent is reduced
  • We don't have to install Jenkins again and again in different systems, we use an image that I created once