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.
- Windows Container Host
- JENKINS setup file
- Go to the URL https://jenkins.io/download/
- Scroll down and click on the Windows link
- It prompts us to download the zip file.
- Once the download is complete and extracts the MSI from the ZIP file.
PREPARING BUILD ENVIRONMENT
- Create a folder named Jenkins in C:\ drive using below command
New-Item -Type Directory -Name jenkins -Path c:\
- Create one more folder name source inside C:\jenkins folder.
New-Item -Type Directory -Name setup -path C:\jenkins\
- Create a filename dockerfile inside c:\jenkins folder.
New-Item -Type File -Name dockerfile -Path C:\jenkins\
- Copy the downloaded jenkins setup file to c:\jenkins\setup folder.
- 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
#COPY THE JENKINS INSTALLATION FILES INTO THE CONTAINER
ADD ./setup c:/jenkins
RUN Powershell.exe -Command Install-WindowsFeature Web-Server
RUN ["msiexec.exe", "/i", "C:\\jenkins\\jenkins.msi", "/qn"]
#REMOVING SETUP FILES FROM CONTAINER
RUN Powershell.exe -Command remove-item c:/jenkins –Recurse
BUILDING THE IMAGE
- Go-to PowerShell and execute the below command to build the jenkins image.
docker build -t jenkins c:\jenkins
- It will take several minutes to complete the build.
- Launch a new container using the Jenkins image which we built earlier.
docker run -it jenkins powershell
- Once the container is created, type ipconfig to find the IP address.
- Browse the IP along with port 8080 from your container host. It prompts for the initial administrator password to configure Jenkins.
- Type the below command to view the administrator password from the initialadminpassword file.
type ‘C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword’
- Copy & paste the password and click continue.
- 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.
- It will take few minutes to complete the installation.
- In next screen, it prompts for to create a new admin user. Provide the details and click save and finish.
- The final screen shows that Jenkins is ready. Click on Start using Jenkins button.
- Now jenkins is available for our environment.
- You can download the pre-built image from the Docker Hub URL
- Also, you can download the dockerfile from GitHub URL.
Thanks for reading this blog. We hope it was useful for you to learn to how to install Jenkins in windows container.