Building Custom Windows 10 Docker image: With installed external software

I need some assistance in creating a custom Windows docker image.
I am running Windows 10 Pro and have installed Docker Desktop.

The image needs the following software available:

  1. .NET Framework 4.8 Developer Pack: Microsoft download/dotnet-framework/net48
  2. Windows 10 SDK: Windows downloads/windows-10-sdk
  3. WiX Toolset
  4. .NET Framework 3.5 Runtime: Needed to install Wix Toolset
  5. AdoptOpenJDK OpenJDK 11 Hotspot
  6. AdoptOpenJDK OpenJDK 14 Hotspot

All the software I wish to install on the docker image is installed on the host OS I am building on.

I thought I could combine several existing images that gives me parts of these

FROM adoptopenjdk:11-jdk-hotspot AS jdk11
FROM adoptopenjdk:14-jdk-hotspot AS jdk14
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS sdk
FROM mcr.microsoft.com/dotnet/framework/runtime:3.5 AS runtime

If I could use the sdk as base image, I would not need Windows 10 SDK in order to get the signtool.exe, since the sdk contains the signtool.exe.

But it does not look feasible.
I have read that the base image I use must be the same as the Windows host I am running. That be a Windows 10 base image.

FROM mcr.microsoft.com/windows:1903

How can I silent install software in a Docker image when the installation is using a GUI?

I have tried to use Powershell cmdlets to install the .NET Framework SDK and Runtime:

RUN Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -All
RUN Enable-WindowsOptionalFeature -Online -FeatureName "NetFx4" -All

Or directly with dism command line tool:

RUN dism /Online /Enable-Feature /All /FeatureName:NetFx3 /NoRestart
RUN dism /Online /Enable-Feature /All /FeatureName:NetFx4 /NoRestart

However both these fails with “The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.”.

It should enable the feature, and download it. It will try Windows Update, but I reckon it is not available when building docker image.

I have seen some examples with Powershell for silent installation, but what if the software I need does not have command line install capability?

RUN powershell Start-Process C:\wiz.exe -ArgumentList '/WhatArgumentAreNeeded' -Wait ; \
    Remove-Item C:\wix.exe --Force;

This does not seem to work when I try it. It starts the GUI, and I cannot find any information on WiX Toolset if it is possible with silent install.


When it comes to the AdoptOpenJDK OpenJDK images, I was thinking of copying them from their images to the base image:
COPY --from=jdk11 [ "C:\Program Files\AdoptOpenJDK/jdk-11.*-hotspot", "C:/Program Files/Java/jdk-11" ]
COPY --from=jdk11 [ "C:\Program Files\AdoptOpenJDK/jdk-14.*-hotspot", "C:/Program Files/Java/jdk-14" ]

Then set JAVA_HOME and the appropriate PATH environment variables.

Found a solution to the error I got with Powershell cmdlets or DISM.
After I enabled the Windows Update service as I could find here

Set-Service -Name wuauserv -StartupType "Manual"

However, I could only find .NET Framework 3.5 (NetFx3) as a Feature I could enable. The 4.8 SDK was not available as a feature using Enable-WindowsOptionalFeature, Add-WindowsCapability or DISM.

Still looking to find solutions to silent install

  • .NET Framework SDK 4.8
  • WiX Toolset
  • Windows 10 SDK

Would appreciate any help how to install these on a Windows Docker image:

  • .NET Framework SDK 4.8
  • WiX Toolset
  • Windows 10 SDK

I think I can do a workaround for the WiX Toolset. By downloading the wix311-binaries.zip and unpack instead of installing the wix311.exe
However the WiX download page does seem to indicate the ZIP is for other purposes than installing the Toolset.

I have seen other workarounds.

  1. Install WiX with Chocolatey
  2. Building a Linux docker with Wine to run WiX Toolset.

Otherwise I am completely stuck. Not sure how to install either of these three on a Windows Docker image.

I was able to install WiX Toolset through Chocolatey in the Docker image.

Having trouble installing the Windows 10 SDK.
I downloaded the ISO, unpacked it, and tried to silently install its MSI files with powershell.
Unfortunately it just hangs.

RUN $msifile = '"C:\19041.1.191206-1406.vb_release_WindowsSDK\Installers\Windows SDK Signing Tools-x86_en-us.msi"'; `
    Start-Process -FilePath msiexec.exe -ArgumentList '/i',$msifile,'/qn','/norestart' -Wait -PassThru;

The docker build just hangs there forever…

I have worked around this problem, by not installed OpenJDK. I downloaded the ZIP archives and unpacked them.

Now I have to install the OpenJDK with the MSI installer. It is the only way for Gradle to detect Java Toolchains on Windows, if the JDK is installed and have a registry key.

I still have not found out why it hangs when running docker build

# escape=`

FROM mcr.microsoft.com/windows:1903 AS jdk11

SHELL [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Install OpenJDK 11
ADD https://api.adoptopenjdk.net/v3/installer/latest/11/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk?project=jdk C:\openjdk11.msi
RUN Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\openjdk11.msi", "ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome", "INSTALLDIR='C:\Program Files\Java'", /quiet;

Does anyone have a solution to get this working?