Docker issues: unable to install visual c++ runtime on windows docker image

  asp.net-core, c#, docker, dockerfile, visual-c++-2015

I have a 64 bit C++ command line exe that needs to be run in a docker and be invoked in a ASP.NET Core Web API project. C++ app depends on installing Visual C++ redistributable, but I cant seem to be able to install it inthe docker image. As an example, I made the simplest application possible, and modified DockerFile to (what I understood would) install vc_redist.x64.exe. This is my DockerFile (Lines 1 through 3 are the only modifications I made to an out of the box DockerFile VS made for me when I created the project)

FROM mcr.microsoft.com/windows/servercore:ltsc2022
ADD https://aka.ms/vs/16/release/vc_redist.x64.exe vc_redist.x64.exe
RUN vc_redist.x64.exe /install /quiet /norestart /log vc_redist.log

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["WebApplication1/WebApplication1.csproj", "WebApplication1/"]
RUN dotnet restore "WebApplication1/WebApplication1.csproj"
COPY . .
WORKDIR "/src/WebApplication1"
RUN dotnet build "WebApplication1.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "WebApplication1.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApplication1.dll"]

when building the image i see this output (partial output):

PS C:UsersxxxxxxxxDesktopWebApplication1> docker build -f .WebApplication1Dockerfile -t webapp1:test .
Sending build context to Docker daemon  48.13kB
Step 1/19 : FROM mcr.microsoft.com/windows/servercore:ltsc2022
 ---> 5afa3c742f5a
Step 2/19 : ADD https://aka.ms/vs/16/release/vc_redist.x64.exe vc_redist.x64.exe
Downloading [==================================================>]  25.17MB/25.17MB

 ---> a7dbd1d4c8b7
Step 3/19 : RUN vc_redist.x64.exe /install /quiet /norestart /log vc_redist.log
 ---> Running in 968e1e6d213e
Removing intermediate container 968e1e6d213e
 ---> 4532598daa9b
Step 4/19 : FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
 ---> 641e5dcab948
...

When I run the application and watch the procmon, i can see that the C++ application is invoked but is unable to load because it cant find msvcp140.dll/vcruntime140.dll/etc.. components of VC++ runtime. Furthermore, if I exec into the docker container, I can’t locate any of the dlls manually, nor do I see the vc_redist.x64.exe or the log file it supposed to output when installed.

Any help is appreciated.

Source: Docker Questions

LEAVE A COMMENT