skip to Main Content

I have a .NET 7 application running in a Linux docker container, on an Ubuntu machine. I’m unable to attach Visual Studio (on Windows 11) to my application. I can connect to other .NET applications inside Docker on other Ubuntu machines.

I get this error:
Failed to launch debug adapter ‘coreclr’.
VsDbgRemoteUnixLauncher only supports remote Unix machines!

The Attach-to-process wizard can see the containers and can see the processes inside those containers, so it doesn’t seem to be a problem with the ssh connection.

I haven’t found anything online on this error.

Extra info: Output of Debug Adapter Host Log, after running this command: DebugAdapterHost.Logging /On /OutputWindow

 1> DebugAdapterHost version: 17.6.10530.1 commit:a8b80a80533cc2b91039497e292d6997b60501a6
 1> ERROR: Failed to launch debug adapter!

DebugAdapterLaunchException: Failed to launch debug adapter.  Additional information may be available in the output window.

Failure Location: LaunchingProcess
Inner Exception: 
    InvalidOperationException: VsDbgRemoteUnixLauncher only supports remote Unix machines!

Microsoft.VisualStudio.Debugger.VsDbg.Integration.AdapterLauncher.VsDbgRemoteUnixLauncher.Microsoft.VisualStudio.Debugger.DebugAdapterHost.Interfaces.IAdapterLauncher.LaunchAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterProcessConnection..ctor(ConfigurationWrapper configuration, IDiagnosticLogger log, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, IAdapterLauncher launcher)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterHostFactory.CreateDebugAdapterHost(ConfigurationWrapper configuration, IDiagnosticLogger log, ExtensibilityManager extensibilityManager, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, Boolean registerStandardHandlers, DebugProtocolOptions options, Action`1 syncRequestErrorHandler)

 1> ERROR: Unexpected error

DebugAdapterLaunchException: Failed to launch debug adapter.  Additional information may be available in the output window.

Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterHostFactory.CreateDebugAdapterHost(ConfigurationWrapper configuration, IDiagnosticLogger log, ExtensibilityManager extensibilityManager, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, Boolean registerStandardHandlers, DebugProtocolOptions options, Action`1 syncRequestErrorHandler)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterHostFactory.CreateDebugAdapterHost(DebuggedProcess process, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.Engine.Implementation.DebuggedProcess.StartDebugAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop)

Failure Location: LaunchingProcess
Inner Exception: 
    InvalidOperationException: VsDbgRemoteUnixLauncher only supports remote Unix machines!

Microsoft.VisualStudio.Debugger.VsDbg.Integration.AdapterLauncher.VsDbgRemoteUnixLauncher.Microsoft.VisualStudio.Debugger.DebugAdapterHost.Interfaces.IAdapterLauncher.LaunchAdapter(IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterProcessConnection..ctor(ConfigurationWrapper configuration, IDiagnosticLogger log, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, IAdapterLauncher launcher)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.AdapterHosting.DebugAdapterHostFactory.CreateDebugAdapterHost(ConfigurationWrapper configuration, IDiagnosticLogger log, ExtensibilityManager extensibilityManager, IAdapterLaunchInfo launchInfo, ITargetHostInterop targetInterop, Boolean registerStandardHandlers, DebugProtocolOptions options, Action`1 syncRequestErrorHandler)

 1> ERROR: Failed to launch debug adapter.  Additional information may be available in the output window.

VsDbgRemoteUnixLauncher only supports remote Unix machines!

2

Answers


  1. Chosen as BEST ANSWER

    I've got it working! I troubleshooted the issue by using auditd to log the commands Visual Studio was executing on the docker host. By executing these commands manually, I had a lot more info on what went wrong.

    In my case, this command failed:

    docker exec -i myapp /bin/sh -c 'echo shell-process:$$ >> /proc/[0-9]*/cmdline; for filename in /proc/[0-9]*/cmdline 2>/dev/null; do echo -e "nfilename:$filenamen" && cat $filename; done'
    

    It failed because the directory .docker in the home-directory of the SSH user used to remote debug, was owned by root. Changing the owner to the correct user fixed my issue.

    For anyone reading this having a similar, but not the same issue: Install and start auditd, add these rules at the end of /etc/audit/rules.d/audit.rules:

    -a exit,always -F arch=b32 -S execve -k auditcmd
    -a exit,always -F arch=b64 -S execve -k auditcmd
    

    Then run these commands:

    augenrules 
    service auditd stop
    service auditd start
    

    Try attaching in VS, then execute:

    ausearch -ua userYouUseForSshConnection
    

    This will display all commands executed by that user. Probably the last one will indicate the problem.


  2. Given the base image is mcr.microsoft.com/dotnet/aspnet:7.0-alpine and the result of uname inside the container is Linux, that means the container itself should be a compatible Unix environment for remote debugging with Visual Studio.

    As a workaround, you can try running the application outside of Docker to isolate whether the issue is Docker-specific or related to the application’s configuration.

    I can find only this other case, which points out to:

    • "Debug .NET Core on Linux using SSH by attaching to a process Prerequisites": make sure those have been followed
    • some logs: "Can you grab additional logs by going to the Command Window (View -> Other Windows -> Command Window) and enter DebugAdapterHost.Logging /On /OutputWindow. This will drop additional logs in the Output pane if you switch to Show output from: Debug Adapter Host Log."

    In the context of Docker and remote debugging, a firewall could also potentially be an issue. Even if the application is running inside a Docker container on an Alpine Linux base image, network communication between your Windows 11 machine running Visual Studio and the Docker container on the remote Ubuntu machine would go through the network stack of the host machine, which is subject to the host’s firewall settings.

    ┌──────────────────┐     SSH (TCP/22)    ┌──────────────────┐ Docker Port Mapping  ┌──────────────────┐
    │ Windows 11       │────────────────────►│ Ubuntu Machine   │◄────────────────────►│ Docker Container │
    │ Machine          │                     │                  │                      │                  │
    │ ┌──────────────┐ │                     │ ┌──────────────┐ │                      │ ┌──────────────┐ │
    │ │ Visual       │ │                     │ │ SSH Daemon   │ │                      │ │ .NET App     │ │
    │ │ Studio       │ │                     │ │ (sshd)       │ │                      │ │              │ │
    │ └──────────────┘ │                     │ └──────────────┘ │                      │ └──────────────┘ │
    │                  │                     │                  │                      │ │ VsDbg        │ │
    │                  │                     │                  │                      │ └──────────────┘ │
    └──────────────────┘                     └──────────────────┘                      └──────────────────┘
    

    When debugging a .NET application remotely with Visual Studio, several ports could be involved, depending on the configuration and the services used. Make sure port 22 (or your configured SSH port) is open for incoming connections on the Ubuntu machine.

    sudo ufw allow 22/tcp
    

    Find out which port VsDbg is using and make sure it is open. If it is dynamic, you might need to set up a specific port and expose it when starting the Docker container.

    docker run -d -p <host-port>:<container-debug-port> myapp:tag
    sudo ufw allow <host-port>/tcp
    

    Make sure your Docker run command exposes the necessary ports, e.g., -p 8080:80 would expose port 80 from the container to port 8080 on the host.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search