Here is to how you can install JENKINS through dockerfile for Windows container on Windows 2016.
REQUIREMENTS:
-
Windows Container Host
-
JENKINS setup file
DOWNLOAD JENKINS:
-
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:
New-Item -Type Directory -Name jenkins -Path c:\
New-Item -Type Directory -Name setup -path C:\jenkins\
New-Item -Type File -Name dockerfile -Path C:\jenkins\
Here is the DOCKER FILE :
FROM microsoft/windowsservercore #SPECIFY THE CONTAINER IMAGE
ADD ./setup c:/jenkins #COPY THE JENKINS INSTALLATION FILES INTO THE CONTAINER
RUN Powershell.exe -Command Install-WindowsFeature Web-Server #INSTALLING IIS
RUN ["msiexec.exe", "/i", "C:\\jenkins\\jenkins.msi", "/qn"] #INSTALLING JENKINS
RUN Powershell.exe -Command remove-item c:/jenkins –Recurse #REMOVING SETUP FILES FROM CONTAINER
BUILDING THE IMAGE:
docker build -t jenkins c:\jenkins
-
It will take several minutes to complete the build.
-
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 the required environment.