Docker Community Forums

Share and learn in the Docker community.

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.

Open a terminal window (Command Prompt or PowerShell, but not PowerShell ISE).

Run docker --version to ensure that you have a supported version of Docker:

docker --version

Docker version 19.03.1
Pull the hello-world image from Docker Hub and run a container:

docker run hello-world

docker : Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

List the hello-world image that was downloaded from Docker Hub:

docker image ls
List the hello-world container (that exited after displaying “Hello from Docker!”):

docker container ls --all
Explore the Docker help pages by running some help commands:

docker --help
docker container --help
docker container ls --help
docker run --help

Not sure what you are suggesting here for my problem.
Windows has docker 19.03.8 installed.
I have no problem running docker images. I am looking for information how to build docker images with 3party installed software.

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…