CodexBloom - Programming Q&A Platform

Visual Studio 2022 - Debugging scenarios with 'Access Denied' scenarios on ASP.NET Core App Running with Docker

πŸ‘€ Views: 0 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-18
visual-studio docker aspnet-core C#

I'm working with a frustrating scenario when trying to debug my ASP.NET Core application in Visual Studio 2022 while it is running in a Docker container... Every time I attempt to attach the debugger to the process, I get the behavior message: `Access denied`. I've checked the Docker settings, and I have enabled the option to allow debugging, but it still doesn't seem to work. My Dockerfile is set up properly, and I'm using the `mcr.microsoft.com/dotnet/aspnet:6.0` base image. Here’s a snippet of my Dockerfile: ```dockerfile 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 [YourProjectName].csproj . RUN dotnet restore "[YourProjectName].csproj" COPY . . WORKDIR "/src/.” RUN dotnet build "[YourProjectName].csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "[YourProjectName].csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "[YourProjectName].dll"] ``` I’ve also made sure that the Docker extension in Visual Studio is up to date. To further troubleshoot, I tried running the container as an administrator, but the same behavior continues. I've been using the `docker-compose` tool to manage my containers, and my `docker-compose.override.yml` looks like this: ```yaml yml version: '3.4' services: webapp: image: ${DOCKER_REGISTRY-}webapp environment: - ASPNETCORE_ENVIRONMENT=Development ports: - "5000:80" ``` Additionally, I've verified my firewall settings and there are no restrictions that would block the debugger. I’ve also tried using the command line to start the container manually with `docker run`, but I still need to attach the debugger. Has anyone else faced this scenario? What could I be missing here? This is my first time working with C# 3.11. What's the best practice here? I'm on Ubuntu 20.04 using the latest version of C#. I appreciate any insights!