Installing JENKINS Through Docker File For Windows Container

Installing JENKINS through Docker File For Windows Container

In this blog, we will show you installing JENKINS through docker file for Windows container onWindowss 2016.

REQUIREMENTS

  • Windows Container Host
  • JENKINS setup file

DOWNLOAD JENKINS

installing JENKINS through docker file for Windows container
  • Scroll down and click on the Windows link
installing JENKINS through docker file for Windows container
  • It prompts us to download the zip file.
installing JENKINS through docker file for Windows container
  • Once the download is complete and extracts the MSI from the ZIP file.
installing JENKINS through docker file for Windows container

PREPARING BUILD ENVIRONMENT

  • Create a folder named Jenkins in C:\ drive using below command

New-Item -Type Directory -Name jenkins -Path c:\

installing JENKINS through docker file for Windows container
  • Create one more folder name source inside C:\jenkins folder.

New-Item -Type Directory -Name setup -path C:\jenkins\

installing JENKINS through docker file for Windows container
  • Create a filename dockerfile inside c:\jenkins folder.

New-Item -Type File -Name dockerfile -Path C:\jenkins\

Installing JENKINS through docker file for Windows container
  • Copy the downloaded jenkins setup file to c:\jenkins\setup folder.
Installing JENKINS through docker file for Windows container
  • Open the dockerfile in the notepad and add the below code and save it.

#THIS DOCKER FILE IS DEVELOPED BY ASSISTANZ NETWORKS

#SPECIFY THE CONTAINER IMAGE
FROM microsoft/windowsservercore

#COPY THE JENKINS INSTALLATION FILES INTO THE CONTAINER
ADD ./setup c:/jenkins

#INSTALLING IIS
RUN Powershell.exe -Command Install-WindowsFeature Web-Server

#INSTALLING JENKINS
RUN [“msiexec.exe”, “/i”, “C:\\jenkins\\jenkins.msi”, “/qn”]

#REMOVING SETUP FILES FROM CONTAINER
RUN Powershell.exe -Command remove-item c:/jenkins –Recurse

Installing JENKINS through docker file for Windows container

BUILDING THE IMAGE

  • Go-to PowerShell and execute the below command to build the jenkins image.

docker build -t jenkins c:\jenkins

Installing JENKINS through docker file for Windows container
  • It will take several minutes to complete the build.
Installing JENKINS through docker file for Windows container
CONFIGURE JENKINS
  • Launch a new container using the Jenkins image which we built earlier.

docker run -it jenkins powershell

Installing JENKINS through docker file for Windows container
  • Once the container is created, type ipconfig to find the IP address.
Installing JENKINS through docker file for Windows container
  • Browse the IP along with port 8080 from your container host. It prompts for the initial administrator password to configure Jenkins.
Installing JENKINS through docker file for Windows container
  • Type the below command to view the administrator password from the initialadminpassword file.

type ‘C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword’

Installing JENKINS through docker file for Windows container
  • Copy & paste the password and click continue.
Installing JENKINS through docker file for Windows container
  • In the next screen, select the plugins to be installed for your environment. For this demo, we have installed all the suggested plugins for Jenkins.
Installing JENKINS through docker file for Windows container
  • It will take few minutes to complete the installation.
Installing JENKINS through docker file for Windows container
  • In next screen, it prompts for to create a new admin user. Provide the details and click save and finish.
Installing JENKINS through docker file for Windows container
  • The final screen shows that Jenkins is ready. Click on Start using Jenkins button.
Installing JENKINS through docker file for Windows container
  • Now jenkins is available for our environment.
Installing JENKINS through docker file for Windows container
  • You can download the pre-built image from the Docker Hub URL

https://hub.docker.com/r/assistanz247/jenkins-windows/

  • Also, you can download the dockerfile from GitHub URL.

https://github.com/assistanz247/JENKINS

VIDEO

Thanks for reading this blog. We hope it was useful for you to learn to how to install Jenkins in windows container.

Loges