.netdockerpowershellpowershell-corepowershell-7.3

Installing exe inside Windows container using PowerShell


I am facing problem with installation of .exe file inside docker container:

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS base
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN dotnet tool install --global --version 7.3.11 PowerShell 
ADD https://downloads.unidata.ucar.edu/netcdf-c/4.9.2/netCDF4.9.2-NC4-DAP-64.exe lib/netCDF4.9.2-NC4-DAP-64.exe
RUN start-process -Filepath "C:\lib\netCDF4.9.2-NC4-DAP-64.exe" -Wait -PassThru -ArgumentList "/S" , "/D=C:\NetCdf"

CMD ["pwsh"]

After docker build . all steps are running correctly till installation step... Output shows no file to be process:

Step 6/7 : RUN start-process -Filepath "C:\lib\netCDF4.9.2-NC4-DAP-64.exe" -Wait -PassThru -ArgumentList "/S" , "/D=C:\NetCdf"
 ---> Running in 8e200fa39c0f

 NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName
 ------    -----      -----     ------      --  -- -----------
      0     0.00       0.00       0.00    1544

Removing intermediate container 8e200fa39c0f

Checked manually and by "RUN Get-ChildItem -Path "C:\lib\netCDF4.9.2-NC4-DAP-64.exe" that file is present.

Checked by running...

FROM mcr.microsoft.com/windows:20H2 AS base

ADD https://downloads.unidata.ucar.edu/netcdf-c/4.9.2/netCDF4.9.2-NC4-DAP-64.exe lib/netCDF4.9.2-NC4-DAP-64.exe
RUN powershell Start-Process -filepath 'C:\lib\netCDF4.9.2-NC4-DAP-64.exe' -Wait -PassThru -ArgumentList '/S' , '/D=C:\NetCdf'

...that for old normal PowerShell application is installed correctly:

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    168      11     1724       8688       0.09   2292   1 netCDF4.9.2-NC4-DA...

Executing command manually inside container also worked


Is there any related known bug with pwsh tool? Is there better way to install this file with CMD or even dotnet somehow? I spent whole day on trying to make it work, so any help would appreciated :)


Solution

  • I was not able to install any .exe file with mcr.microsoft.com/dotnet/sdk:7.0 - this one is too limited. Instead I used aspnet:7.0-windowsservercore-ltsc2022 and there powershell scripts worked.