Visual Studio Tools for Docker – PrepareForCompile task failed unexpectedly

I took a clean machine (Windows 10 Enterprise w/out the Anniversary Update) and installed (in this order) Full IIS, Hyper-V, VS2015 Enterprise, .NET Core 1.0.1 Tooling Preview 2, Docker for Windows, Visual Studio Docker Tools, and a few other random programs.

I then opened VS2015 and created a default .NET core website. When I run (F5) all works as expected. I then right clicked on the project and went to “Add->Docker Support”. Now when trying to run (F5) using Docker I see this error message:

  • Running elasticsearch in docker
  • docker how to commit but exclude directory from image
  • Running ASP.NET Core with HTTPS in docker from Visual Studio 2015
  • Docker commands fails (in Windows)
  • Upload local files to docker container
  • Jenkins: Don't want to trigger on Git Tag (No Workspace)
  • MSB4018 The "PrepareForCompile" task failed unexpectedly. Microsoft.DotNet.Docker.CommandlineClientException: Error response from daemon: Container ... is not running at ...

    I have searched online and the only thing I can find that might explain it is that I don’t think Shared Drives are working. I did set it up in Docker->Shared Drives, but when I run:
    docker run --rm -v c:/Users:/data alpine ls /data
    the response is empty.

    Likewise when I try using busy box the directory is empty.

    docker run -it -v /C/Users:/wormhole busybox
    cd wormhole

    I have tried using Windows for Docker 1.12.1-stable and beta 26. Both have the same issue.

    Some have indicated that Antivirus could cause a problem. I do have Mcafee installed, but I cannot uninstall or disable the antivirus software.

    Some have suggested that passwords with unusual characters can cause this issue but that does not apply here.

    I don’t know that shared drives are causing the VS2015 error, but it seems like a good place to start since shared drives are broken.

    I have restarted bot hdock and the computer many times, to no avail.

    Any Ideas?

  • Why does uWSGI fail to start in Docker?
  • Dockerfile if else condition with external arguments
  • Windows 7 - Error: connect ENOENT //./pipe/docker_engine
  • Working monitoring solution for Docker Containers and Swarm?
  • What is the difference between lmctfy and lxc
  • Docker container with Blazegraph Triple Store not working possibly due to networking
  • 2 Solutions collect form web for “Visual Studio Tools for Docker – PrepareForCompile task failed unexpectedly”

    I had the same issue.

    In order to fix it I found the container referenced by the id in the stack trace. Then I removed it:

    docker rm <containerid>

    When I tried running from VS 2015 again it worked. I don’t know what initially caused the issue.

    I just wanted to add since I also stumbled upon this issue. I had a clean Win 10 machine, and I just had to enable the “Shared Drive” setting in docker:

    This may not be the actual problem that you’re facing (Thankfully you fixed it!); this is just for people that may not have this enabled!

    Step 1: Right Click on Docker Icon in taskbar

    Step 2: Click Settings

    Step 3: Click Shared Drives. Select the Checkbox for your hard drive, and click "Apply"

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.