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
• 19,610 points
6,217 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
• 59,230 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
1,011 views
0 votes
0 answers

How do I actually install Docker on Windows 8.1? (Docker Toolbox for Windows 8.1 was deprecated recently)

So I have been advised something like ...READ MORE

Apr 21, 2022 in Docker by pranav
• 2,590 points
795 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
• 52,350 points
779 views
+2 votes
1 answer
+2 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
• 58,020 points
2,714 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
• 59,230 points
1,648 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP