Reputation: 10045
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:
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:
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!
Upvotes: 34
Views: 27646
Reputation: 381
Add the Project under "File sharing" UI in docker:
Upvotes: 7
Reputation: 263956
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.
Upvotes: 31
Reputation: 10045
Making drive C: available to Docker containers from the Docker Dashboard solved the problem, look at the picture once again where it was not checked.
A couple of comments must be shared IMHO, however.
A very simple explanation why this quite useless message was displayed may exist - Linux developers type a lot (CLI!) and being not very happy with this they do not type enough to give a meaningful diagnostics to their users.
Well, I do believe I am not right, but still there must be an explanation why such a huge omission appears in a final product.
Upvotes: 18
Reputation: 11
pull the long "docker run ... /dev/null" command out of the output and run it by itself at a docker enabled command prompt. Docker desktop should then prompt to allow sharing/network access. You might want to restart the Docker Desktop app before doing so.
Upvotes: 1