Visual Studio 2019 error CTC1001: Volume sharing is not enabled

Viewed 1239

I'm trying to build a docker image for my NETCORE application, but when I run "Build Docker image" menu from Visual Studio, it throw an error:

failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount861662899/dockerfile: no such file or directory 5>C:\Users\xxxx.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.9.10\build\Container.targets(198,5): error CTC1001: Volume sharing is not enabled. On the Settings screen in Docker Desktop, click Shared Drives, and select the drive(s) containing your project files.

When I try to enable volume sharing, I'm unable to find that option on my Docker settings. All docs says it should be under "Resources" option.

Docker settings

I'm using WSL2 integration, but don't know if it have something to do with the issue.

3 Answers

I faced same issues with WSL 2 and then I just look into Microsoft.VisualStudio.Azure.Containers.Tools.Targets package version used in. It was outdated and then I just install compatible version to my project using package manager, in my case it is 1.10.8 and then It this works for me.

Install-Package Microsoft.VisualStudio.Azure.Containers.Tools.Targets -Version 1.10.8

It might be cause of you set Docker OS Type to linux, but Docker works as Windows container. Try to "Switch to Linux containers" in context menu of Docker tray icon or change settings of in your .csproj file:

<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>

To solve this, just go to settings > resources > wsl integration and mark the integration as enabled:enter image description here

Related