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
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:
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:
Then run these commands:
Try attaching in VS, then execute:
This will display all commands executed by that user. Probably the last one will indicate the problem.
Given the base image is
mcr.microsoft.com/dotnet/aspnet:7.0-alpine
and the result ofuname
inside the container isLinux
, 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:
View -> Other Windows -> Command Window
) and enterDebugAdapterHost.Logging /On /OutputWindow
. This will drop additional logs in the Output pane if you switch toShow 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.
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.
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.
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.