I’ve created Dockerfiles to build a container that runs Jenkins in a windows container.
FROM microsoft/windowsservercore
RUN powershell -Command wget 'http://javadl.oracle.com/webapps/download/AutoDL?BundleId=210185' -Outfile 'C:\jreinstaller.exe' ; Start-Process -filepath C:\jreinstaller.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91" ; del C:\jreinstaller.exe
ENV JAVA_HOME c:\\Java\\jre1.8.0_91
RUN setx PATH %PATH%;%JAVA_HOME%\bin
CMD [ "java.exe" ]
I’ve created the image using:
docker build -t windows-java:jre1.8.0_91 .
The second Dockerfile is for installing Jenkins on top of this:
FROM windows-java:jre1.8.0_91
ENV HOME /jenkins
ENV JENKINS_VERSION 2.58
RUN mkdir \jenkins
RUN powershell -Command "wget -Uri https://updates.jenkins-ci.org/latest/jenkins.war -UseBasicParsing -OutFile /jenkins/jenkins.war
EXPOSE 8080
EXPOSE 50000
CMD java -jar C:\\jenkins\\jenkins.war
docker build -t jenkins-windows:2.0 .
Finally, I launch the container:
docker run --name jenkinsci -p 8080:8080 -p 50000:50000 jenkins-windows:2.0
The output looks good
PS C:\Users\mandeep\ringba\ringba-jenkins-setup-windows\jenkins-master> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
85ba2ef525a1 jenkins-windows:2.0 "cmd /S /C 'java -..." 8 hours ago Up 8 hours 0.0.0.0:8080->8080/tcp, 0.0.0.0:50000->50000/tcp jenkinsci
But I can’t seem to access the Jenkins server running on http://localhost:8080 on the host machine's web browser.
Any help would be appreciated
This is a common issue on Windows. You cant access a container endpoint from its own host using localhost/127.0.0.1. It is possible using Linux containers though.