Reputation: 13990
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.
I'm using WSL2 integration, but don't know if it have something to do with the issue.
Upvotes: 7
Views: 4203
Reputation: 449
Rather late than never.
I was getting the same error. This error can be misleading, In my case I am using postgres, so in my docker-compose.yml file I added an extra letter S on the image: postgress. So when docker tried to pull this image it could not find it, it resulted in the "volume sharing" error but as we can see the issue was the spelling postgress, this must be postgres (single letter S at the end)
Don't just look at the Error List window on visual studio, also inspect the Output window, it might contain the actual cause of the volume sharing error, see below:
Upvotes: 1
Reputation: 151
To solve this, just go to settings > resources > wsl integration and mark the integration as enabled:
Upvotes: 0
Reputation: 1267
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
Upvotes: 10
Reputation: 302
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>
Upvotes: 0