Visualstudio-docs: Problems running the container

Created on 8 Feb 2020  Â·  15Comments  Â·  Source: MicrosoftDocs/visualstudio-docs

The image seems to build fine, only get one warning in step 6:

Step 6/6 : CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
 ---> [Warning] Shell-form ENTRYPOINT and exec-form CMD may have unexpected results

However - when I try to run the container:

C:\BuildTools>docker run -it buildtools2019
docker: Error response from daemon: container 88c9fbab1a05f2d4825b859e84187653b1b9b32a826cdcc9a5dd57171cfb6aa8 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF751989D2B: (caller: 00007FF75193E13A) Exception(2) tid(3a0) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"\"cmd /S /C C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat \u0026\u0026\" powershell.exe -NoLogo -ExecutionPolicy Bypass","WorkingDirectory":"C:\\","Environment":{"COMPLUS_NGenProtectedProcess_FeatureEnabled":"0","NUGET_VERSION":"4.4.3","ROSLYN_COMPILER_LOCATION":"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\Roslyn"},"EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[30,120]}.

Any thoughts?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 doc-bug visual-studio-windowprod vs-installatiotech

Most helpful comment

Thanks @TBBle for the link. It is a good suspect but sadly there is no docker image available yet for dotnet/framework/sdk based on build 1809. BUT replacing the base image with mcr.microsoft.com/windows/servercore:10.0.17763.1039 worked.

All 15 comments

I hit exactly the same issue.
https://github.com/moby/moby/issues/39779

Fix:
ENTRYPOINT ["C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&"]

@Naninani - that helped, thanks. Thereafter however I ran into the following. Did you experience that as well? Running docker 19.03.5.

docker: Error response from daemon: container a25f33fe25eb9f652ff8f6803a8e825bdfe84a022ab8679d3444eb04e380f180 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF793A1AE77: (caller: 00007FF7939CE4AB) Exception(2) tid(384) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"\"cmd /S /C [\\\"C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat\\\", \\\"\u0026\u0026\\\"]\" powershell.exe -NoLogo -ExecutionPolicy Bypass","WorkingDirectory":"C:\\","Environment":{"COMPLUS_NGenProtectedProcess_FeatureEnabled":"0","DOTNET_RUNNING_IN_CONTAINER":"true","DOTNET_USE_POLLING_FILE_WATCHER":"true","NUGET_VERSION":"5.3.1","ROSLYN_COMPILER_LOCATION":"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\Roslyn"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.

Same error as @rlordcardano. C:\BuildTools doesn't exist in the container.

Docker Version: 19.03.5

Also tried to install vs build tools as described within a docker container, but the visual studio installer exits immediately with no warning, no error and no installed files:

C:\>vs_buildtools.exe -quiet --wait --norestart --nocache --installPath C:\BuildTools
C:\>
C:\>echo %ERRORLEVEL%  
0
C:\>

I also tried installing vs build tools 2019 using Chocolatey, which definitely worked some weeks ago, but now the installation fails also there:

choco install visualstudio2019buildtools
...
...
ERROR: Running ["C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\visualstudio2019buildtools\16.4.5.0\vs_BuildTools.exe" --quie
t --norestart --wait] was not successful. Exit code was '-1073741502'. See log for possible error messages.
The install of visualstudio2019buildtools was NOT successful.

I don't know if it's worthy of a new issue or here will be fine but there seems to be an issue with building this image using latest version of Windows Server 2019. vs_buildtools.exe will crash with the error code -1073741502 and collect.exe will crash with the error code -1. Replacing the default shell with cmd instead of powershell will produce another error code, 3221225794. This is a VM running on VMWare.

-1073741502 and 3221225794 are the same error code, 0xc0000142 == STATUS_DLL_INIT_FAILED

@pwuertz @Thoorium You might be having an unrelated issue to this ticket, you're probably having the same issue I just discovered I was having, due to an issue in the February 11, 2020 security update, particularly the "applications silently failing" symptom.

Thanks @TBBle for the link. It is a good suspect but sadly there is no docker image available yet for dotnet/framework/sdk based on build 1809. BUT replacing the base image with mcr.microsoft.com/windows/servercore:10.0.17763.1039 worked.

@Thoorium - what's your full docker file? Using this image gets me a few steps further, but no BuildTools folder is present in the container. Based on latest suggestion in https://github.com/MicrosoftDocs/visualstudio-docs/issues/3713 by @Simran-B I have now arrived at:

# escape=`

# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/windows/servercore:10.0.17763.1039

# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]

# Download the Build Tools bootstrapper.
ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe

# Install Build Tools excluding workloads and components with known issues.
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
    --installPath C:\BuildTools `
    --all `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
    --remove Microsoft.VisualStudio.Component.Windows81SDK `
 || IF "%ERRORLEVEL%"=="3010" EXIT 0

# Start developer command prompt with any other commands specified.
CMD [ "C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass" ]

# Default to PowerShell if no other command specified.
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

@rlordcardano Are you definitely running Windows 10.0.17763.1039 on the host? Try taking --quiet off the vs_buildtools command-line, and make sure it outputs something. If there's absolutely no output, and it's done really quickly, then you're still seeing KB4542617, which means that your host kernel and base image are on different sides of 10.0.17763.1039.

If that's the case, and your host _is_ 10.0.17763.1039, perhaps try

FROM mcr.microsoft.com/windows/servercore:10.0.17763.1040

which is the advice from KB4542617. It's also what you should get _now_ if you use

FROM mcr.microsoft.com/windows/servercore:ltsc2019

according to both KB4542617 and the DockerHub listing for mcr.microsoft.com/windows/servercore, but using the explicit version will ensure you're not seeing a local cached ltsc2019 tag which pointed at 10.0.17763.973 or earlier.

@rlordcardano Here's my dockerfile. As per what @TBBle said, you need to check if your host has the February 11 patch or not. Mine had it.

# escape=`

# mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019 prefered by currently broken.
# See https://support.microsoft.com/en-us/help/4542617/you-may-encounter-issues-when-using-windows-server-docker-container-im
ARG FROM_IMAGE=mcr.microsoft.com/windows/servercore:10.0.17763.1039
FROM ${FROM_IMAGE}

# Copy our Install script.
COPY Install.cmd C:\TEMP\

# Download collect.exe in case of an install failure.
ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe

# Use the latest release channel. For more control, specify the location of an internal layout.
ARG CHANNEL_URL=https://aka.ms/vs/16/release/channel
ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman

# Download and install Build Tools excluding workloads and components with known issues.
ADD https://aka.ms/vs/16/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
    --installPath C:\BuildTools `
    --channelUri C:\TEMP\VisualStudio.chman `
    --installChannelUri C:\TEMP\VisualStudio.chman `
    --includeRecommended `
# Add your workload here. As per https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019 
# Example for web development tools: 
# --add Microsoft.VisualStudio.Workload.WebBuildTools `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
    --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
    --remove Microsoft.VisualStudio.Component.Windows81SDK

# Start developer command prompt with any other commands specified.
ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat &&

Install.cmd is

@if not defined _echo echo off
setlocal enabledelayedexpansion

call %*
if "%ERRORLEVEL%"=="3010" (
    exit /b 0
) else (
    if not "%ERRORLEVEL%"=="0" (
        set ERR=%ERRORLEVEL%
        call C:\TEMP\collect.exe -zip:C:\vslogs.zip

        exit /b !ERR!
    )
)

Thanks @Thoorium / @TBBIe - I have version 10.0.18363.657, so have updated that in the above docker image. After removing the quiet flag, I still get the following error message:

The command 'cmd /S /C C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --wait --norestart
--nocache     --installPath C:\BuildTools     --channelUri C:\TEMP\VisualStudio.chman
--installChannelUri C:\TEMP\VisualStudio.chman     --includeRecommended
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393
--remove Microsoft.VisualStudio.Component.Windows81SDK' returned a non-zero code: 2148734499

2148734499 is 0x80131623 (or _-2146232797‬_), so that's a different error code than the problem from KB4542617.

So I believe your Docker file is now using the right FROM (matching the host), and something else is wrong.

If you put the --quiet flag back, does it give the same error code? It's possible it's trying to do something with the GUI, and failing due to being inside a container.

Your actual error code appears to be COR_E_FAILFAST and suggests a failed assertion in C# code, which means that as least the C# code is running. ^_^

@TBBle - my bad then, I removed the quiet as a precaution to see if anything would fail. Adding it back does the trick, now have a working docker container as it seems. Will do some testing and report back if I have issues, but thanks for now!

Did need to change the entrypoint bit to:

CMD [ "C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass" ]

by the way, but that was reported above already.

Hi @rlordcardano, we've updated the Build Tools documentation here. Please give the new instructions a try. We look forward to your feedback, and I'll be closing out this issue in the meantime.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChrisMaddock picture ChrisMaddock  Â·  3Comments

DaanV2 picture DaanV2  Â·  4Comments

wittelw picture wittelw  Â·  3Comments

nitinjs picture nitinjs  Â·  3Comments

michael-hawker picture michael-hawker  Â·  4Comments