Jus*_*hli 6 debugging docker docker-compose visual-studio-code asp.net-core
我有几个使用 docker-compose 进行 Docker 化的 ASP.NET Core (6.0) WebApi 项目。对于本地开发,我使用 docker-compose 文件,该文件引用在调试模式下构建/发布项目的 Dockerfile。然后,为了进行调试,我使用“Docker .NET Core Attach (Preview)”启动配置并选择相应的 docker 容器,然后该容器会提示我将 .NET Core 调试器复制到容器中。
直到最近,这一直有效,我可以在容器内进行调试。现在突然间,在出现提示并尝试将调试器复制到容器中后,我总是收到以下错误:
开始:“docker”exec -i web_roomservice /remote_debugger/vsdbg --interpreter=vscode
来自管道程序“docker”的错误:致命错误:无法初始化调度程序,错误为80131534
管道程序“docker”意外退出,代码为255。
我尝试重新安装 Docker Engine + docker-compose (使用最新版本),重新安装 VS Code + “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"
Run Code Online (Sandbox Code Playgroud)
(还有更多,但我只包含了这一项服务的部分)
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"]
Run Code Online (Sandbox Code Playgroud)
(此 Dockerfile 放置在工作区文件夹(实际 RoomService 项目文件夹的父级)中,以便包含Common项目)
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker .NET Core Attach (Preview)",
"type": "docker",
"request": "attach",
"platform": "netCore",
"sourceFileMap": {
"/src/RoomService": "${workspaceFolder}"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
(此启动配置放置在实际 RoomService 项目文件夹的 .vscode 子文件夹中)
| 归档时间: |
|
| 查看次数: |
3789 次 |
| 最近记录: |