Cannot install Visual Studio inside a server core image
Describe the bug I am trying to install VS 2022 build tools inside of a docker container to build an image and use it for our CI builds. I already had an image working, but now I needed to update a dependency so I had to rebuild it (TL; DR: it worked last time I built it).
However, the installation now fails with error code 1603.
I have extracted the VS installation logs from the container and the main issue seems to be this:
Error Information
AppInsightsEvent Name = vs/setupengine/packagefailure
Description = The Windows Installer Service could not be accessed. This can occur if the Windows Installer is not correctly installed. Contact your support personnel for assistance.
TelemetrySession = 'aa0725d0-d978-4bf5-bd3c-8f68d3d9702f' Started = True OptIn=True IsInitialized = False Cloned = True
WatsonEventType = VisualStudioNonFatalErrors2
UTC time = 2024-09-26T12:17:52
I run an sfc /scannow inside brand new container using the image and it did find some corrupted files, so maybe the image itself has issues?
To Reproduce You should be able to reproduce this by building the following Dockerfile (based on the example here, where you can also find the Install.cmd file contents):
# escape=`
# Use the Windows Server Core as base image
FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["cmd", "/S", "/C"]
COPY Install.cmd C:\TEMP\
ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe
ADD https://aka.ms/vs/17/release/channel C:\TEMP\VisualStudio.chman
RUN curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe `
&& (call C:\TEMP\Install.cmd vs_buildtools.exe --quiet --wait --norestart --nocache install `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" `
--channelUri C:\TEMP\VisualStudio.chman `
--installChannelUri C:\TEMP\VisualStudio.chman `
--add Microsoft.VisualStudio.Workload.MSBuildTools `
--add Microsoft.VisualStudio.Workload.ManagedDesktopBuildTools `
--add Microsoft.VisualStudio.Workload.VCTools `
--add Microsoft.VisualStudio.Component.Windows11SDK.22000 `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
--add Microsoft.VisualStudio.Component.VC.ATLMFC) `
&& del /q vs_buildtools.exe
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
Expected behavior The image builds without issues.
Configuration:
- Edition: Windows Server
- Base Image being used:
mcr.microsoft.com/windows/servercore:ltsc2019 - Container engine: Docker
- Container Engine version: 20.10.15
Thank you for creating an Issue. Please note that GitHub is not an official channel for Microsoft support requests. To create an official support request, please open a ticket here. Microsoft and the GitHub Community strive to provide a best effort in answering questions and supporting Issues on GitHub.
@zillemarco Hey, thanks for bringing up this Issue. Have you tried to use a recent Windows Server Core LTSC 2022 image? Or only the 2019 version? I ask because we don't provide support for 2019 anymore.
Hi @ntrappe-msft, I did not because I don't have any server running win2022 and docker, and it wouldn't be a solution anyway because the server the image I'm trying to build is running win2019 unfortunately.
I also tried installing other software in the image, just to make sure it wasn't only related to Visual Studio, but anything I try to install it fail.
Moreover, the last image for ltsc2019 was built and published less than a month ago, so isn't it still kinda supported?
On a Windows LTSC 2022 Image, i receive this error:
https://github.com/docker/for-win/issues/14425
Does anyone know how might resolve it?
On a Windows LTSC 2022 Image, i receive this error:
Does anyone know how might resolve it?
Hey there! Thanks for sharing the error details. The “not enough space on the disk” message often means that Docker’s storage location (typically on the C: drive by default) is running low on available space.
A few things you can try:
1. Check Available Disk Space:
Open File Explorer, go to “This PC” → “Local Disk (C:)” and verify the remaining free space. If it’s low or in the red, you’ll need to free up some space.
2. Increase VM Disk Size (If Applicable):
If you’re running inside a VM, open Hyper-V Manager, expand the size of the attached .vhdx file, then inside the guest OS, use Disk Management to extend the C drive partition. This can give Docker more breathing room.
3. Clean Up Docker Resources:
Run docker volume ls to see if you have old volumes that can be removed. Unused volumes can eat up a lot of space.
Check %localappdata%\Docker\wsl or your Docker storage location for leftover images or layers. Consider running docker system prune -a --volumes to remove dangling images, containers, and volumes (just be careful—you’ll lose anything that’s not currently in use).
4. Adjust Docker Storage Settings:
Since you mentioned you already tried setting the size=30G and increasing memory, double-check your Docker daemon config or explore the Docker docs for storage driver settings and ensure they’re applied correctly. You can also switch the drive Docker uses to store data if C drive isn't big enough.
Hopefully that helps.
@zillemarco When you try to build the image from the Dockerfile, is it failing on a specific line? Or it is dropping that error upon completion?
@zillemarco When you try to build the image from the Dockerfile, is it failing on a specific line? Or it is dropping that error upon completion?
Hi @ntrappe-msft, it's not failing on any specific line of the Dockerfile unfortunately. It just quits after the vs_buildtools.exe installation fails, which fails with error code 1603.
I was able to try the same Dockerfile but on a Windows Server 2022 (obviously the docker base image was changed as well) and that worked, so it seems only relater to running the installed on the servercore:ltsc2019 image.
To be clear: I tested on WinServer 2022 just for the sake of making sure it worked there, we still can't deprecate WinServer 2019 unfortunately.
Update: I just noticed that a new image for ltsc2019 was released a few weeks ago and I just tested it, but it still doesn't work and the installer fails with error code 1603.
The image IDs I tested are:
-
e83f833ac0a1(the one I originally tested and opened this issue for) -
6ebe876cb4c3(the latest one, 5 weeks old, that still doesn't work)
@zillemarco hey, I am having the same issue base on a mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 image, did you find the fix for your issue?
@zillemarco hey, I am having the same issue base on a
mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019image, did you find the fix for your issue?
@ericoporto unfortunately no. We are still stuck at not being able to update some of our docker images due to this bug.
@ntrappe-msft do you have any updates on this? Looking back at your suggestions (https://github.com/microsoft/Windows-Containers/issues/540#issuecomment-2529754613), I checked the available space on our server running docker build, and we are in fact running out of space on the OS disk (on the C drive), but docker is set up to use another one which has 700+ GB of available space so I don't think it's a space issue.
For "fun" I tested another Dockerfile we used to generate a Docker image with VS2017 and, ... still the same error.
The windowsservercore-ltsc2019 image is broken.
For me, the only solution is to clean the whole Docker System every time with
docker system prune
when building an image with Visual Studio
@madduci thanks for the suggestion but it unfortunately did not work for me.
BTW, I also tried upgrading our docker and we are now running 27.4.1, but the issue still persists.
Hi @zillemarco, I wonder if the following approach may help you, Try the following command in an admin level powershell prompt, this explicitly calls the curl command from the Dockerfile to install VS buildtools:
cmd /c "curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe"
Hi @zillemarco, I wonder if the following approach may help you, Try the following command in an admin level powershell prompt, this explicitly calls the curl command from the Dockerfile to install VS buildtools:
cmd /c "curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe"
Hi @sabinamiezah-msft, just to clarify, how would you like me to run that command? Do you mean from inside a container running the ltsc2019 image?
And what's the output you'd be expecting? From inside the container I can't run the installer like that because there's no UI.
This issue has been open for 30 days with no updates. @ntrappe-msft, please provide an update or close this issue.
Hi @zillemarco, I was looking into your issue recently and I found that there was a more recently released document to Install VS Build Tools into a container. When I tested out this approach (replacing the image specified in the Dockerfile with a 2019 servercore image, it worked well for me). I wonder if this may help you with your issue?
This is what my Dockerfile looks like:
# escape=`
# Use the latest Windows Server Core 2019 image.
ARG FROM_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2019
FROM ${FROM_IMAGE}
# Restore the default Windows shell for correct batch processing.
SHELL ["cmd", "/S", "/C"]
# 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/17/release/channel
ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman
RUN `
# Download the Build Tools bootstrapper.
cmd /c "curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe" `
`
# Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues.
&& (call C:\TEMP\Install.cmd vs_buildtools.exe --quiet --wait --norestart --nocache install `
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" `
--channelUri C:\TEMP\VisualStudio.chman `
--installChannelUri C:\TEMP\VisualStudio.chman `
--add Microsoft.VisualStudio.Workload.AzureBuildTools `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
--remove Microsoft.VisualStudio.Component.Windows81SDK) `
`
# Cleanup
&& del /q vs_buildtools.exe
# Define the entry point for the Docker container.
# This entry point starts the developer command prompt and launches the PowerShell shell.
ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
This issue has been open for 30 days with no updates. @sabinamiezah-msft, please provide an update or close this issue.
Going stale, closing.