英文:
Debugging Docker-Compose in VS2019 fails with .Net Core SDK errors
问题
对不起,我只会翻译非代码部分,以下是您要翻译的内容:
So, I wanted to learn about and try Docker-Compose in a project of mine. The project consists of 6 ASP.Net Core standalone services, all equipped with the auto-generated dockerfile.
All projects are running on .Net Core 3.1, and their dockerfiles also reflect this.
Example dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY .... (Some copies here I did cut out)
RUN dotnet restore "Services/MooMed.Stateful.SessionService/MooMed.Stateful.SessionService.csproj"
COPY .
WORKDIR "/src/Services/MooMed.Stateful.SessionService"
RUN dotnet build "MooMed.Stateful.SessionService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MooMed.Stateful.SessionService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MooMed.Stateful.SessionService.dll"]
VS then generates the following docker-compose.yml:
moomed.stateful.sessionservice:
image: ${DOCKER_REGISTRY-}moomedstatefulsessionservice
build:
context: .
dockerfile: Services/MooMed.Stateful.SessionService/Dockerfile
With the corresponding docker-compose.override.yml:
moomed.stateful.sessionservice:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports: - "80"
- "443"
volumes: - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
This is the error log I get when trying to debug docker-compose:
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
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 'dotnet' has exited with code 145 (0x91).
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 'dotnet' has exited with code 145 (0x91).
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 'dotnet' has exited with code 145 (0x91).
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 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 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 'dotnet' has exited with code 145 (0x91).
The program 'dotnet' has exited with code 145 (0x91).
The program 'dotnet' has exited with code 145 (0x91).
Please note that the docker-compose does run all 6 services, and I only listed files for one of them to save you from the wall of text.
However, all dotnet commands fail the same way.
I should note, that when running services in Docker from VS individually is no problem at all, it works perfectly fine, so I suppose the Dockerfiles are not necessarily wrong. As much as I read up about the build section in the docker-compose, it should also just explicitly go about working with the given Dockerfiles, just like when I do it myself.
So, what might be going wrong here?
EDIT: Some more info... I also created a fresh default Asp.Net Core app in the meantime, ran it through docker-compose with dockerfiles and a compose yaml basically equal to this one besides the references, and there are no problems whatsoever there.
EDIT2: Also tried to docker-compose up
manually now, this works perfectly. Could this be tied to the vsdbg stuff the debug compose launch function in VS does? I mean I have no idea how Visual Studio does this stuff, but possibly VS transforms the yaml
英文:
So, I wanted to learn about and try Docker-Compose in a project of mine. The project consists of 6 ASP.Net Core standalone services, all equipped with the auto-generated dockerfile.
All projects are running on .Net Core 3.1, and their dockerfiles also reflect this.
Example dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY .... (Some copies here I did cut out)
RUN dotnet restore "Services/MooMed.Stateful.SessionService/MooMed.Stateful.SessionService.csproj"
COPY . .
WORKDIR "/src/Services/MooMed.Stateful.SessionService"
RUN dotnet build "MooMed.Stateful.SessionService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MooMed.Stateful.SessionService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MooMed.Stateful.SessionService.dll"]
VS then generates the following docker-compose.yml:
moomed.stateful.sessionservice:
image: ${DOCKER_REGISTRY-}moomedstatefulsessionservice
build:
context: .
dockerfile: Services/MooMed.Stateful.SessionService/Dockerfile
With the corresponding docker-compose.override.yml:
moomed.stateful.sessionservice:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "80"
- "443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
This is the error log I get when trying to debug docker-compose:
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
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 'dotnet' has exited with code 145 (0x91).
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 'dotnet' has exited with code 145 (0x91).
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 'dotnet' has exited with code 145 (0x91).
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 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 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 'dotnet' has exited with code 145 (0x91).
The program 'dotnet' has exited with code 145 (0x91).
The program 'dotnet' has exited with code 145 (0x91).
Please note that the docker-compose does run all 6 services, and I only listed files for one of them to save you from the wall of text.
However, all dotnet commands fail the same way.
I should note, that when running services in Docker from VS individually is no problem at all, it works perfectly fine, so I suppose the Dockerfiles are not necessarily wrong. As much as I read up about the build section in the docker-compose, it should also just explicitly go about working with the given Dockerfiles, just like when I do it myself.
So, what might be going wrong here?
EDIT: Some more info... I also created a fresh default Asp.Net Core app in the meantime, ran it through docker-compose with dockerfiles and a compose yaml basically equal to this one besides the references, and there are no problems whatsoever there.
EDIT2: Also tried to docker-compose up
manually now, this works perfectly. Could this be tied to the vsdbg stuff the debug compose launch function in VS does? I mean I have no idea how Visual Studio does this stuff, but possibly VS transforms the yaml to include download of vsdbg, the entry args are then given to the debugger which starts up the app, and this would then fail because the container does not have required commands. Something like this possibly. However, if this would be the case it would also fail when doing a normal debug of a single service without docker-compose.
答案1
得分: 4
是的,问题出在特殊字符的使用。
问题的原因仅仅是我的文件夹结构中有一个/C#/目录。将其重命名为/C-Sharp/,现在它可以正常工作。
英文:
Yeah, good old special character problem.
The culprit was simply having a /C#/ in my folder structure. Renamed it to /C-Sharp/ and now it works.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论