简体   繁体   English

如何在 Docker、Windows 10、WSL 2 中调试

[英]How to debug in Docker, Windows 10, WSL 2

When I try to run Debug F5 from VS 2019 using Docker I see the following error当我尝试使用 Docker 从 VS 2019 运行调试 F5 时,我看到以下错误

C:\Users\comet.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.9.10\build\Container.targets(198,5): error CTC1001: Volume sharing is not enabled. C:\Users\comet.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.9.10\build\Container.targets(198,5): 错误 CTC1001: 卷共享未启用。 On the Settings screen in Docker Desktop, click Shared Drives, and select the drive(s) containing your project files.在 Docker 桌面的设置屏幕上,单击共享驱动器,然后单击 select 包含项目文件的驱动器。

I have WSL2 and latest Docker Desktop, google says that sharing is already done automatically so Desktop has no such Setting at all我有 WSL2 和最新的 Docker 桌面,谷歌说共享已经自动完成,所以桌面根本没有这样的设置

I had the same problem with an older project.我在一个较旧的项目中遇到了同样的问题。 Creating a new project with docker support worked fine.使用 docker 支持创建一个新项目工作正常。 The difference I found that the old project file had:我发现旧项目文件的不同之处在于:

<OutputType>Exe</OutputType>

and the new project did not have that line, so I removed it.而新项目没有那条线,所以我把它去掉了。 Also updated the targets:还更新了目标:

    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />

This solved it for me这为我解决了

To start docker in WSL2 Ubuntu 20.04在 WSL2 Ubuntu 20.04 中启动 docker

first start wsl2 

then run the command below to start docker daemon然后运行以下命令启动 docker 守护进程

sudo /etc/init.d/docker start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM