使用' Docker .Net Core attect'不再工作了
我有几个使用docker-compose对接的ASP.NET Core(6.0)WebAPI项目。对于本地开发,我使用了一个Docker-Compose文件,该文件引用了以调试模式构建 /发布项目的Dockerfiles。然后,为了调试,我使用“ Docker .Net Core Attact(Preview)”启动配置并选择相应的Docker容器,然后提示我将.NET Core Debugger复制到容器中。
直到最近,这始终可以工作,我可以在容器内进行调试。现在突然被提示并试图将调试器复制到容器中后,我总是会收到以下错误:
开始:“ docker” exec -i web_roomservice /remote_debugger /vsdbg - interpreter = vscode
管道程序“ docker”中的错误:致命错误:无法使用错误初始化调度员80131534
管道程序“ Docker”意外地使用代码255。
我尝试重新安装Docker Engine + Docker-Compose(带有最新版本),重新安装vs代码 + docker'和'docker'和'c#'扩展,从ASP迁移.NET Core 5.0至6.0(因为不再支持5.0),显然多次重建我的图像,但似乎没有任何作用,我在网上找不到任何东西。对此的任何帮助将不胜感激,因为到目前为止,我无法调试哪个很烂。
这些是我的Docker-Compose,Debug-dockerfile和启动配置(对于一个项目 /服务):(
version: "3.7"
services:
roomservice:
image: web_roomservice
container_name: web_roomservice
build:
context: ./
dockerfile: Dockerfile.RoomService.Debug
expose:
- "5011"
volumes:
- /etc/localtime:/etc/localtime:ro
environment:
- ASPNETCORE_ENVIRONMENT=Development
user: "root:root"
logging:
driver: "json-file"
options:
max-size: "5m"
还有更多,但我只在此服务中包括了该部分)
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
#EXPOSE 5011
ENV ASPNETCORE_URLS=http://+:5011
# Install netpbm which is used for .pgm to .png file conversion for map images
RUN apt-get -y update --silent
RUN apt-get -y install netpbm --silent
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["RoomService/RoomService.csproj", "./RoomService/"]
COPY ["EventBusRabbitMQ/EventBusRabbitMQ.csproj", "./EventBusRabbitMQ/"]
COPY ["Common/Common.csproj", "./Common/"]
RUN dotnet restore "RoomService/RoomService.csproj"
COPY RoomService ./RoomService
COPY EventBusRabbitMQ ./EventBusRabbitMQ
COPY Common ./Common
WORKDIR "/src/RoomService"
RUN dotnet build "RoomService.csproj" -c Debug -o /app/build
FROM build AS publish
RUN dotnet publish "RoomService.csproj" -c Debug -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RoomService.dll"]
(此DockerFile放置在Workspace文件夹(实际RoomService Project文件夹的父母)中,以包括 common 项目)
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker .NET Core Attach (Preview)",
"type": "docker",
"request": "attach",
"platform": "netCore",
"sourceFileMap": {
"/src/RoomService": "${workspaceFolder}"
}
}
]
}
(此启动配置放置在实际的RoomService项目文件夹的.VSCODE子文件夹中)
I have several ASP.NET Core (6.0) WebApi projects that are dockerized using docker-compose. For local development, I use a docker-compose file which references Dockerfiles that build / publish the projects in Debug mode. Then in order to debug, I use the 'Docker .NET Core Attach (Preview)' launch configuration and select the corresponding docker container, which then prompts me about copying the .NET Core debugger into the container.
Until recently, this always worked and I could debug inside the container. Now suddenly, after being prompted and trying to copy the debugger into the container, I always get the following error:
Starting: "docker" exec -i web_roomservice /remote_debugger/vsdbg
--interpreter=vscode
Error from pipe program 'docker': FATAL ERROR: Failed to initialize dispatcher with error 80131534
The pipe program 'docker' exited unexpectedly with code 255.
I tried re-installing the Docker Engine + docker-compose (with the latest version), re-installing VS Code + the 'Docker' and 'C#' extensions, migrating from ASP.NET Core 5.0 to 6.0 (since 5.0 is not supported anymore) and obviously rebuilding my images multiple times, but nothing seems to work and I can't find anything online. Any help with this would be greatly appreciated, since as of now I can't debug which sucks.
These are my docker-compose, Debug-Dockerfile and launch config (for one project / service):
version: "3.7"
services:
roomservice:
image: web_roomservice
container_name: web_roomservice
build:
context: ./
dockerfile: Dockerfile.RoomService.Debug
expose:
- "5011"
volumes:
- /etc/localtime:/etc/localtime:ro
environment:
- ASPNETCORE_ENVIRONMENT=Development
user: "root:root"
logging:
driver: "json-file"
options:
max-size: "5m"
(There's more but I only included the section with this one service)
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
#EXPOSE 5011
ENV ASPNETCORE_URLS=http://+:5011
# Install netpbm which is used for .pgm to .png file conversion for map images
RUN apt-get -y update --silent
RUN apt-get -y install netpbm --silent
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-dotnet-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["RoomService/RoomService.csproj", "./RoomService/"]
COPY ["EventBusRabbitMQ/EventBusRabbitMQ.csproj", "./EventBusRabbitMQ/"]
COPY ["Common/Common.csproj", "./Common/"]
RUN dotnet restore "RoomService/RoomService.csproj"
COPY RoomService ./RoomService
COPY EventBusRabbitMQ ./EventBusRabbitMQ
COPY Common ./Common
WORKDIR "/src/RoomService"
RUN dotnet build "RoomService.csproj" -c Debug -o /app/build
FROM build AS publish
RUN dotnet publish "RoomService.csproj" -c Debug -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "RoomService.dll"]
(This Dockerfile is placed in the workspace folder (parent of the actual RoomService project folder) in order to include the Common project)
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker .NET Core Attach (Preview)",
"type": "docker",
"request": "attach",
"platform": "netCore",
"sourceFileMap": {
"/src/RoomService": "${workspaceFolder}"
}
}
]
}
(This launch configuration is placed in the actual RoomService project folder's .vscode subfolder)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
今天有同样的问题。如果您在MacOS上,请尝试删除〜/vsdbg目录。
Had the same problem today. Try deleting the ~/vsdbg directory, if you are on MacOS.
下面的此配置在
.net6
中完美工作。.vscode/lunaine.json
文件的内容:我还在我的
dotnet debugger
中安装了 dockerfile 如下:youtube中介绍了完整的指令教程: debugging .net .net core in Docker with vscode docker
This configuration below works perfectly in
.NET6
.content of
.vscode/launch.json
file:I have also installed
dotnet debugger
in myDockerfile
as follow:Full instruction is covered in this YouTube tutorial: Debugging .NET Core in Docker with VSCode
大卫是对的。我遇到了同样的问题。我正在运行wsl2(ubuntu),当我删除
〜/.vsdbg
目录时,我为我解决了问题。David is right. I was having the same issue. I am running WSL2 (Ubuntu) and when I deleted the
~/.vsdbg
directory that fixed the issue for me.今天,当我的Mac上的Visual Studio代码1.89.1调试到运行.NET Core应用程序的Docker容器时,我们遇到了这个问题。我们还遇到了错误“致命错误:无法使用错误80131534初始化调度器”。
我们发现使用VSDBG版本17.0.10712.2为我们工作。我们通过更改将VSDBG下载的Dockerfile的线路来完成此操作:
如果它可以帮助其他任何人,我们使用.NET SDK 6.0.423,然后使用Microsoft.aspnetcore.App.App 6.0.31和Microsoft.netcore.netcore.app 6.0。 31。我们的容器正在运行Debian.11-ARM64。
We had this problem today when trying to debug from Visual Studio Code 1.89.1 on my Mac into a docker container running a .NET Core application. We were also getting the error "FATAL ERROR: Failed to initialize dispatcher with error 80131534".
We found that using version 17.0.10712.2 of vsdbg worked for us. We did this by altering the line of our Dockerfile that downloads vsdbg to this:
In case it helps anyone else, we are using .NET SDK 6.0.423, with Microsoft.AspNetCore.App 6.0.31 and Microsoft.NETCore.App 6.0.31. Our container is running debian.11-arm64.