×
Installing JENKINS through Docker File For Windows Container
Blog Containers

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.

8 thoughts on “Installing JENKINS through Docker File For Windows Container”

  1. Hi,
    thanks for the good guide. How can i handle persistent data, in case of changing to a container with a newer Jenkins version?

    BR
    Mario

  2. Hi,

    I am trying to install Jenkins through Docker , by following the steps you have given.
    But I am getting the following error :

    Sending build context to Docker daemon 122.4MB
    Step 1/5 : FROM microsoft/windowsservercore
    —> 8d57c0984795
    Step 2/5 : ADD ./setup c:/jenkins
    —> Using cache
    —> 6c1aa7b19915
    Step 3/5 : RUN Powershell.exe -Command Install-WindowsFeature Web-Server
    —> Using cache
    —> f89508a781d4
    Step 4/5 : RUN [“msiexec.exe”, “/i”, “C:/jenkins/setup/jenkins.msi”, “/qn”]
    —> Running in ee0df67c146e
    ‘[“msiexec.exe”’ is not recognized as an internal or external command,
    operable program or batch file.
    The command ‘cmd /S /C [“msiexec.exe”, “/i”, “C:/jenkins/setup/jenkins.msi”, “/qn”]’ returned a non-zero code: 1

    Could you please help?

  3. Hi Arc,

    Thanks for reading this blog. We have tried this code and its work on our end. Can you please use the below code

    #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

    Regards,
    Loges

  4. Hello Loges,

    Very useful article. Thankyou.

    I’m looking at how to persist the changes made to the windows container. As I could not commit or checkpoint the running windows container.

    Could you please help ?

  5. hI ,
    i AM GETTING THIS BELOW ERRO CAN YOU PLEASE RESOLVE THIS.

    PS C:\WINDOWS\system32> docker build -t jenkins D:\jenkins
    unable to prepare context: unable to evaluate symlinks in Dockerfile path: GetFileAttributesEx D:\jenkins\Dockerfile: The system cannot find the file specified.
    PS C:\WINDOWS\system32> docker build -t jenkins C:\jenkins
    Sending build context to Docker daemon 122.5MB
    Step 1/5 : FROM microsoft/windowsservercore
    —> 824f26e4c566
    Step 2/5 : ADD ./setup c:/jenkins
    —> Using cache
    —> 67f09c2b1e55
    Step 3/5 : RUN Powershell.exe -Command Install-WindowsFeature Web-Server
    —> Using cache
    —> e1764b74965c
    Step 4/5 : RUN [“msiexec.exe”, “/i”, “D:\\jenkins\\jenkins.msi”, “/q”]
    —> Running in f0750fc3adea
    T h i s i n s t a l l a t i o n p a c k a g e c o u l d n o t b e o p e n e d . V e r i f y t h a t t h e p a c k a g e e x i s t s a n d t h a t y o u c a n a c c e s s i t , o r c o n t a c t t h e a p p l i c a t i o n v e n d o r t o v e r i f y t h a t t h i s i s a v a l i d W i n d o w s I n s t a l l e r p a c k a g e .
    The command ‘msiexec.exe /i D:\jenkins\jenkins.msi /q’ returned a non-zero code: 1619

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.