How do i install jenkins using a dockerfile on a windows container?

+1 vote
I don't want to pull the jenkins image from the docker hub. Can somebody help me with the steps involved in a dockerfile for building a Jenkins image in a windows container? Thanks .
Aug 22, 2019 in Docker by Karan
• 10,080 points
2,055 views

1 answer to this question.

+1 vote

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:

  • 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.

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:

  • 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.

  • 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.

answered Aug 22, 2019 by Sirajul
• 53,090 points
how to mount the volume?

Related Questions In Docker

+1 vote
1 answer
0 votes
1 answer

How do I install docker on windows?

Hey @Dipti, Follow these steps to install ...READ MORE

answered Feb 25, 2019 in Docker by Kalgi
155 views
0 votes
1 answer

How do I get into a Docker container?

docker attach will let you connect to your ...READ MORE

answered Aug 10, 2018 in Docker by Kalgi
• 51,850 points
99 views
0 votes
1 answer

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 27, 2018 in Docker by Damon Salvatore
• 5,540 points
13,855 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 57,530 points
538 views
0 votes
2 answers

How do I start a container and create a volume using a volume driver?

You can first create the volume and ...READ MORE

answered Aug 6, 2019 in Docker by Sirajul
• 53,090 points
140 views