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:
- .NET Framework 4.8 Developer Pack: Microsoft download/dotnet-framework/net48
- Windows 10 SDK: Windows downloads/windows-10-sdk
- WiX Toolset
- .NET Framework 3.5 Runtime: Needed to install Wix Toolset
- AdoptOpenJDK OpenJDK 11 Hotspot
- 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.
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.