Visual-studio – Docker Compose failed to build – Filesharing has been cancelled – eShopOnContainers

asp.net-coredockerdocker-composevisual studio

I am having trouble running a sample ASP.NET MVC Core application provided by a template from Microsoft
(eShopOnContainers).

When I trying to run the project using Visual Studio 2019, the below error is popped.

Severity Code Description Project File Line Suppression State
Error DT1001 ERROR: for payment-api Cannot create container for
service payment-api: status code not OK but 500: {"Message":"Unhandled
exception: Filesharing has been cancelled","StackTrace":" at
Docker.ApiServices.Mounting.FileSharing.d__6.MoveNext()
in
C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\Mounting\FileSharing.cs:line
0\r\n— End of stack trace from previous location where exception was
thrown —\r\n at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
Docker.ApiServices.Mounting.FileSharing.d__4.MoveNext() in
C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\Mounting\FileSharing.cs:line
47\r\n— End of stack trace from previous location where exception
was thrown —\r\n at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
Docker.HttpApi.Controllers.FilesharingController.d__2.MoveNext()
in
C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.HttpApi\Controllers\FilesharingController.cs:line
21\r\n— End of stack trace from previous location where exception
was thrown —\r\n at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Threading.Tasks.TaskHelpersExtensions.d__1`1.MoveNext()\r\n—
End of stack trace from previous location where exception was thrown
—\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()\r\n—
End of stack trace from previous location where exception was thrown
—\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()\r\n—
End of stack trace from previous location where exception was thrown
—\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Dispatcher.HttpControllerDispatcher.d__15.MoveNext()"}
If the error persists, try restarting Docker
Desktop. docker-compose C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 384

Erroe_log

Here is my setup,

  • Microsoft Visual Studio Enterprise 2019 Version 16.6.1
  • docker desktop version 2.3.03

Does anyone have any idea to fix this?

[UPDATE]

The main error is:

Docker.ApiServices.Mounting.FileSharing.<ShareAsync>d__4.MoveNext() in
> C:\\workspaces\\stable-2.3.x\\src\\github.com\\docker\\pinata\\win\\src\\Docker.ApiServices\\Mounting\\FileSharing.cs

Best Answer

It looks like you have not shared the drive your project is on (C:\workspaces?)

You need to update File Sharing configuration in your Docker In New version there is a new security hardening in 2.2.0.0 which has aggressive defaults. Add all folders you need and then restart Docker for Windows.

enter image description here

[UPDATE]

If you are using WSL then according to the documentations

File sharing :
The File sharing tab is only available in Hyper-V mode, because in WSL 2 mode and Windows container mode all files are automatically shared by Windows.

https://docs.docker.com/docker-for-windows/#file-sharing

Thanks to @robby

Related Topic