Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: Drive has not been shared

When "dockerizing" an ASP.NET Core 3.1 MVC application I got the following outcome:

docker run -dt -v "C:\Users\admin\vsdbg\vs2017u5:/remote_debugger:rw" -v "D:\xxx\yyy\Spikes\DockerizedWebApp1\DockerizedWebApp1:/app" -v "D:\xxx\yyy\Spikes\DockerizedWebApp1:/src/" -v "C:\Users\admin\.nuget\packages\:/root/.nuget/fallbackpackages2" -v "C:\Program Files\dotnet\sdk\NuGetFallbackFolder:/root/.nuget/fallbackpackages" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "ASPNETCORE_LOGGING__CONSOLE__DISABLECOLORS=true" -e "ASPNETCORE_ENVIRONMENT=Development" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages2" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages;/root/.nuget/fallbackpackages2" -P --name DockerizedWebApp1 --entrypoint tail dockerizedwebapp1:dev -f /dev/null docker: Error response from daemon: status code not OK but 500: {"Message":"Unhandled exception: Drive has not been shared"}. See 'docker run --help'. C:\Users\admin\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.10.6\build\Container.targets(198,5): error CTC1015: Docker command failed with exit code 125. C:\Users\admin\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.10.6\build\Container.targets(198,5): error CTC1015: docker: Error response from daemon: status code not OK but 500: {"Message":"Unhandled exception: Drive has not been shared"}. C:\Users\admin\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.10.6\build\Container.targets(198,5): error CTC1015: See 'docker run --help'. C:\Users\admin\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.10.6\build\Container.targets(198,5): error CTC1015: If the error persists, try restarting Docker Desktop. 

Needless to say 'docker run --help' did not help at all (missing links/anchors in the Docker docs etc.).

Some additional info:

  • Application is what VS2019 scaffolds without any modifications.
  • Docker image is Linux (which one I cannot tell).
  • Docker version is 19.03.5, build 633a0ea

Since I am not familiar with Linux this error turns out to be like a "show-stopper" to me. Maybe Linux is not instructed to mount a drive? But which one? The message does not say it...

Maybe Windows has to share a drive, or map a folder to a drive that needs to be shared? The message does not say this either...

Here's a screenshot of the Docker dashboard:

enter image description here

And here's the Dockerfile:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.  FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base WORKDIR /app EXPOSE 80  FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src  COPY ["DockerizedWebApp1/DockerizedWebApp1.csproj", "DockerizedWebApp1/"] RUN dotnet restore "DockerizedWebApp1/DockerizedWebApp1.csproj" COPY . . WORKDIR "/src/DockerizedWebApp1" RUN dotnet build "DockerizedWebApp1.csproj" -c Release -o /app/build  FROM build AS publish RUN dotnet publish "DockerizedWebApp1.csproj" -c Release -o /app/publish  FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "DockerizedWebApp1.dl"] 

Any help would be much appreciated. Thanks in advance!

like image 578
Alexander Christov Avatar asked Jan 28 '20 04:01

Alexander Christov


People also ask

How do I enable file sharing in Docker?

In order to share Windows folders with Docker containers, you first need to configure the "Shared Drives" option in Docker settings. Once the Shared Drives option is configured, you can mount any folder on shared drives with the "-v" (volume) flag.

Can Docker containers be shared?

To share Docker images, you have to use a Docker registry. The default registry is Docker Hub and is where all of the images we've used have come from. A Docker ID allows you to access Docker Hub which is the world's largest library and community for container images. Create a Docker ID for free if you don't have one.


1 Answers

The docker run command includes volumes from the C drive, e.g. -v "C:\Users\admin\vsdbg\vs2017u5:/remote_debugger:rw". For these to work, you need to include the C drive in your shared drives (check the box under settings -> resources -> file sharing). You can also move the files to be shared to the D drive which is already shared to the embedded VM, though that is likely not an option in this case. To know which drives to share, check the drives used in volume mounts in the run command.

In previous versions of docker for Windows, this would silently succeed and mount an empty folder into the container. So the error telling users to check the shared drives first is a nice improvement.

like image 99
BMitch Avatar answered Oct 14 '22 03:10

BMitch