I am trying to run the asp.net core app on docker in windows 7. I have Visual Studio 2015 Enterprise (Update 3) and Visual Studio Tools for Docker installed. Also, I am able to run the application in Release configuration.
I have not done any changes to the Dockerfile and compose files, those are default which are created when I created the project and added the Docker Support.
When I am running the application with Debug configuration, I am getting the below error and it is not running any docker containers to run and debug the application:
Error MSB4018 The "PrepareForLaunch" task failed unexpectedly.
System.InvalidOperationException: Unable to validate volume mapping. For troubleshooting, follow instructions from http://aka.ms/DockerToolsTroubleshooting
at Microsoft.DotNet.Docker.BuildTasks.PrepareForLaunch.<ExecuteAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.DotNet.Docker.BuildTasks.DockerBaseTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() SampleCoreApp C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing\ImportAfter\Microsoft.DotNet.Docker.targets 70
Any help or lead solving this issue will be helpful.
This issue is because of some problem with drive mapping here. So, I have removed one of the drive mapping (- .:/app) and also changed the source argument (obj/Docker/empty to .) in the docker-compose.dev.debug.yml file and it worked for me.
Previous file (docker-compose.dev.debug.yml):
version: '2'
services:
samplecoreapp:
build:
args:
source: obj/Docker/empty
labels:
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- DOTNET_USE_POLLING_FILE_WATCHER=1
volumes:
- .:/app
- ~/.nuget/packages:/root/.nuget/packages:ro
- ~/clrdbg:/clrdbg:ro
entrypoint: tail -f /dev/null
After modification:
version: '2'
services:
samplecoreapp:
build:
args:
source: .
labels:
- "com.microsoft.visualstudio.targetoperatingsystem=linux"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- DOTNET_USE_POLLING_FILE_WATCHER=1
volumes:
- ~/.nuget/packages:/root/.nuget/packages:ro
- ~/clrdbg:/clrdbg:ro
entrypoint: tail -f /dev/null
Hope this will be helpful for those who are facing this issue.