Integration of Dockerfile, Jenkins, Git to launch the respective OS in RHEL8 using SSH from Docker Container

Sakshi Tripathi
5 min readJul 12, 2020

Before Starting my task description lemme introduce each keyword in above time …………

What is Docker and why we use it?

Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.[6] Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating system kernel and therefore use fewer resources than virtual machines.The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Solomon Hykes

What is Jenkins?

Jenkins is a free and open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. It is a server-based system that runs in servlet containers such as Apache Tomcat. It supports version control tools, including AccuRev, CVS, Subversion, Git, Mercurial, Perforce, ClearCase and RTC, and can execute Apache Ant, Apache Maven and sbt based projects as well as arbitrary shell scripts and Windows batch commands. The creator of Jenkins is Kohsuke Kawaguchi.[4] Released under the MIT License, Jenkins is free software.

What is Git?

Git is a distributed version-control system for tracking changes in source code during software development.[8] It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed,data integrity, and support for distributed, non-linear workflows.Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development. Its current maintainer since 2005 is Junio Hamano. As with most other distributed version-control systems, and unlike most client–server systems, every Git directory on every computer is a full-fledged repository with complete history and full version-tracking abilities, independent of network access or a central server.

So let back to our task…….

Task Overview:-

When a Developer uploads the code to Github then according to the type of file like HTML, PHP, etc, an OS had launched from the docker in the RHEL8 with the respective software install in it.

This whole process done by the Jenkins jobs, but here Jenkins is running in the Docker container, so to launch the OS in RHEL8 we use SSH terminal commands or SSH plugin in Jenkins.

Tools required to complete our task …😊😊

  1. Docker

2. RHEL8

3. Jenkins

4. Git

5. Github

so lets get dive in the world of technology with me🏄‍♀️🏄‍♀️

Creation of Dockerfile….

Then use the command #docker build -t Jenkins:v1 /ws/

to create an image

when we launch a container from this image it automatically installs wget, git, sudo, java required for Jenkins, Jenkins, and start the service of Jenkins at the port 8080.

Setup of Jenkins

For the first time, we have to set up Jenkins by giving a password, installing various Plugins.

This password can be copied from the location given in the image or when we launch the container, it also gives at that time.

installation of various Plugins

before we move to create the jobs in Jenkins, first make an SSH connection…..

                            ssh -keygen

After ssh -you have to put username@remotehostIP

it’s an important information so i am not sharing any screenshot for this step 😊😊

Now move to Jenkins Jobs………..

Job 1 :

This job downloads the file in the docker container workspace whenever a Developer pushes the file to the respective Github repository. Also, I used scp command — to copy the file in the RHEL8 directory. POLL SCM is used to check every minute whether the new file is uploaded on Github or not.

Job 2 :

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 PHP, then Jenkins should start the container that has PHP already installed ).

Job 3 :

Test your app if it is working or not, if app is not working, then send an email to developer with error messages.

Testing Result….

Job 4 :

Creating One extra job to monitor: If the container where the app is running. fails due to any reason then this job should automatically start the container again.

here is my pipeline……..

So that’s all from this task ……….

Thanks for your time…….

Sakshi Tripathi

Redhat Ansible || Flutter || EKS || Hybrid_Multi_Cloud || MLOps Trainee at LinuxWorld Informatics Pvt Ltd, Pursuing my ambition and gaining knowledge