I spent quite some time on getting this working on Windows with Windows Docker slaves.

In the end it turned out to be mostly matter of using correct Jenkins docker plugin.

Jenkins docker slave

Use Yet Another Docker Plugin With this plugin it just works (Docker Plugin doesn’t work)

Install JAVA into docker image and make it available on PATH

In Configuration add Yet Another Docker Plugin as a Cloud Point it to Docker server Test that it is available Add the docker image Add label which can be references from builds

as a Jenkins now automatically creates a docker container as a build is executed It does not require any additional changes It properly handles the operating system (Windows)

For local only images make sure that the Pull option is set to Never

Base Dockerfile

This Dockerfile creates the base image for Windows build agent

creates the base image for Windows build agent The only requirements is that java.exe must be accessible in path. It could be perhaps even installed using Chocolatey FROM microsoft/windowsservercore SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"] RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) RUN choco install -y git --params='/NoShellIntegration' RUN choco install -y nuget.commandline ENV JAVA_HOME c:\\jre1.8.0_91 ENV JENKINS_HOME c:\\jenkins RUN (new-object System.Net.WebClient).Downloadfile('http://javadl.oracle.com/webapps/download/AutoDL?BundleId=210185', 'C:\jre-8u91-windows-x64.exe') RUN start-process -filepath C:\\jre-8u91-windows-x64.exe -passthru -wait -argumentlist "/s,INSTALLDIR=$env:JAVA_HOME,/L,install64.log" RUN del C:\jre-8u91-windows-x64.exe RUN $env:PATH = $env:JAVA_HOME + '\\bin;' + $env:PATH; \ [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); RUN mkdir $env:JENKINS_HOME WORKDIR $JENKINS_HOME ENTRYPOINT ["cmd.exe"]



Visual Studio 2017 Dockerfile