RUN not working during the Build of a Docker Image


Installed Docker Desktop (v4.16.1) on Windows 10 (21H1, 19044.2364) machine and it works fine.
Created a sample Image for running a Python file and it also works fine.

Now trying to create an Image for building a Windows WPF application.

Did find several DockerFiles, but when running them I get the following error message:
runc run failed: unable to start container process: exec: “cmd”: executable file not found in $PATH

All files will have the same result/error message.

What am I doing wrong or is maybe wrong with my system?
Did try to build it on a fresh Win10 system with only DockerDesktop on it, but the same problem.

Thanks in advance,

Using the following DockerFile:

# escape=`

FROM $REPO:4.8-20221213-windowsservercore-ltsc2019

    # Do not generate certificate
    # NuGet version to install
    NUGET_VERSION=6.4.0 `
    # Install location of Roslyn
    ROSLYN_COMPILER_LOCATION="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\Roslyn"

# Install NuGet CLI
RUN mkdir "%ProgramFiles%\NuGet\latest" `
    && curl -fSLo "%ProgramFiles%\NuGet\nuget.exe" `
    && mklink "%ProgramFiles%\NuGet\latest\nuget.exe" "%ProgramFiles%\NuGet\nuget.exe"

# Install VS components
    # Install VS Test Agent
    curl -fSLo vs_TestAgent.exe `
    && start /w vs_TestAgent --quiet --norestart --nocache --wait --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\TestAgent" `
    && powershell -Command "if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { throw $err }" `
    && del vs_TestAgent.exe `
    # Install VS Build Tools
    && curl -fSLo vs_BuildTools.exe `
    && start /w vs_BuildTools ^ `
        --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" ^ `
        --add Microsoft.Component.ClickOnce.MSBuild ^ `
        --add Microsoft.Net.Component.4.8.SDK ^ `
        --add Microsoft.NetCore.Component.Runtime.6.0 ^ `
        --add Microsoft.NetCore.Component.Runtime.7.0 ^ `
        --add Microsoft.NetCore.Component.SDK ^ `
        --add Microsoft.VisualStudio.Component.NuGet.BuildTools ^ `
        --add Microsoft.VisualStudio.Component.WebDeploy ^ `
        --add Microsoft.VisualStudio.Web.BuildTools.ComponentGroup ^ `
        --add Microsoft.VisualStudio.Workload.MSBuildTools ^ `
        --quiet --norestart --nocache --wait `
    && powershell -Command "if ($err = dir $Env:TEMP -Filter dd_setup_*_errors.log | where Length -gt 0 | Get-Content) { throw $err }" `
    && del vs_BuildTools.exe `
    # Trigger dotnet first run experience by running arbitrary cmd
    && "%ProgramFiles%\dotnet\dotnet" help `
    # Workaround for issues with 64-bit ngen
    && %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen uninstall "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\SecAnnotate.exe" `
    && %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen uninstall "%ProgramFiles(x86)%\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\WinMDExp.exe" `
    # ngen assemblies queued by VS installers
    && %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen update `
    && %windir%\Microsoft.NET\Framework\v4.0.30319\ngen update `
    # Cleanup
    && (for /D %i in ("%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\*") do rmdir /S /Q "%i") `
    && (for %i in ("%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\*") do if not "%~nxi" == "vswhere.exe" del "%~i") `
    && powershell Remove-Item -Force -Recurse "%TEMP%\*" `
    && rmdir /S /Q "%ProgramData%\Package Cache"

# Set PATH in one layer to keep image size down.
RUN powershell setx /M PATH $(${Env:PATH} `
    + \";${Env:ProgramFiles}\NuGet\" `
    + \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\TestAgent\Common7\IDE\CommonExtensions\Microsoft\TestWindow\" `
    + \";${Env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\" `
    + \";${Env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\" `
    + \";${Env:ProgramFiles(x86)}\Microsoft SDKs\ClickOnce\SignTool\")

# Install Targeting Packs
RUN powershell " `
    $ErrorActionPreference = 'Stop'; `
    $ProgressPreference = 'SilentlyContinue'; `
    @('4.0', '4.5.2', '4.6.2', '4.7.2', '4.8', '4.8.1') `
    | %{ `
        Invoke-WebRequest `
            -UseBasicParsing `
            -Uri${_}.zip `
            -OutFile; `
        Expand-Archive -DestinationPath \"${Env:ProgramFiles(x86)}\Reference Assemblies\Microsoft\Framework\.NETFramework\"; `
        Remove-Item -Force; `

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

Where did you find Dockerfiles? Did you change anything in it?

how do you no that the problem is a RUN instruction in a Dockerfile? Can you share the whole build error?

Is “cmd” the actual command after “exec” in the error message? If it is, my guess is that is cmd.exe. In this case it probably means it tries to run cmd.exe which can’t be found in the base image. I can’t see any sign of executing cmd.exe but it could be the default command, or shell.

Files are located in: Docker

I didn’t change anything in it.
I’m using the first (4.8.1) file from “Windows Server Core 2022 amd64 Tags”

Here is the console output of the docker build:

It’s trying to run cmd /s /c, but is this cmd.exe not available in the image?
If not, how can I get this Dockerfile working?


Try to run the base image and run the commands manually in the container. That way you will see which command fails exactly and if the container has cmd.exe or not.

Strange, since you don’t use cmd directly in the Dockerfile so it must be the default shell but I don’t see anything that suggests you changed the shell so the base image should be wrong too.

Run the following command, please

docker image history

I can’t test it on Windows now, but the result can show the default shell too.