1

I am not familiar with Windows containers, and I am getting this error when trying to debug a hello-world DotNet 6 application in VS2022:

Cannot use file stream for [C:\app\bin\Debug\net6.0\WebApplication5.runtimeconfig.json]: Permission denied
Invalid runtimeconfig.json [C:\app\bin\Debug\net6.0\WebApplication5.runtimeconfig.json] [C:\app\bin\Debug\net6.0\WebApplication5.runtimeconfig.dev.json]
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[13360] dotnet.exe' has exited with code 2147516563 (0x80008093).

Dockerfile (default):

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat

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

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

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "WebApplication5.dll"]

I tried to spin the container in an interactive way, to validate if the file was actually there but this command did not work:

docker run -it --entrypoint powershell.exe webapplication5
docker: Error response from daemon: container 8581fd662043dbfad4a2b68e561d21c106e4754b6f21c4d06cfb9b3d5e2b0a39 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2).

What can the problem be? Why I cannot get a PS inside the container?

Carlos Garcia
  • 2,771
  • 1
  • 17
  • 32
  • I'm pretty sure that mcr.microsoft.com/dotnet/aspnet:6.0 is a Linux image only. You also use forward-slash in your paths etc. Try `docker run -it --entrypoint /bin/bash webapplication5` and see if you get a prompt. – Hans Kilian Jan 03 '22 at 23:40
  • Thanks @HansKilian! I think there are images for both OS, linux and windows. I am using the windows one. I added `USER Administrator` and it worked. I need to figure out what is the user the image is using by default on windows and grant permissions to that folder I guess – Carlos Garcia Jan 03 '22 at 23:57

1 Answers1

2

My docker user needs more permissions. I solved it in an easy way because it is for testing.. don't do this at home, and grant the minimum permissions instead:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
# Here is the risky trick
USER Administrator 
Carlos Garcia
  • 2,771
  • 1
  • 17
  • 32