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:

  • Connect to Docker Swarm for Continuous deploy
  • Emscripten “incoming” installation unusually big
  • Can I bind a port while building a docker image?
  • How to allow a range of ports in Kubernetes in containerPort variable?
  • Can't build docker image via gradle on Windows 10
  • How to make odoo read admin_passwd from file?
  • 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?

  • apachectl -DFOREGROUND exits immediately
  • Unable to install Npsql via nuget
  • Automated build with docker-compose (Application+mySQL server)
  • Sharing precompiled assets across docker containers
  • Deploying to dockerized Jboss Zip Exception
  • Execute script inside docker container which is folder different than WORKDIR
  • 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.