I have a windows server 2019 and try to run a docker windows container. I try to mount a volume like this:
docker run -it -v d:\test\:d:\test\ mcr.microsoft.com/dotnet/framework/sdk:4.8 cmd.exe
It should mount the local folder d:\test in the container under the same path d:\test
Actual behavior
but I get this error massage:
cleanup: failed to delete container from containerd: no such container
docker: Error response from daemon: hcsshim::CreateComputeSystem: The parameter is incorrect.
But the following examples work fine:
docker run -it -v c:\test\:c:\test\ mcr.microsoft.com/dotnet/framework/sdk:4.8 cmd.exe
docker run -it -v d:\test\:c:\test\ mcr.microsoft.com/dotnet/framework/sdk:4.8 cmd.exe
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 as base
VOLUME ["D:"]
But still the same error.
So why does docker only allow me to mount to c drive?
I canāt really change the mount part of the docker run command since it comes from jenkins. Do I need to create the d drive in the image differently? Is there any way I can debug this farther? How do you mount to a Windows Container a drive that is not C?
Thats not how that works im afraid, the āVOLUMEā command just gives the information to docker, that its possible to mount d:, but it dosnt validate anything, its more like an info.
Im not sure that you can just create d:, but im not a big windows guy so im not sure
It looks like you can create a volume and that way create a D drive, but you canāt mount anything to that drive. I would just use the C drive, but if your application expects to be a D drive, you could trycreating a symbolic link from D:\test to C:\test and still mount your local folder to C:\test. I donāt know the reason of this behavior, but Linux doesnā have drive letters like Windows, so when you create a volume in the Dockerfile, it will just create a folder on your host and mount it to the container. You canāt and you donāt need to specify on which partition or disk, because those are on the host. Windows containers have limitations compared to Linux containers, but sometimes there can be features for Windows which does not make sense on Linux. I donāt know how that D drive is created in the container, but it is possible that it just creates a virtual drive. If that drive somehow takes time to be mounted it will not be there when the container starts.
I am just guessing. I tried to figure out how Windows creates that drive, but I still donāt know.
So, all comments above are correct. To add on top of that: Thereās no D drive on windows containers by default and the option you provided on Docker doesnāt work on Windows containers.
On a regular Windows system, drives are usually assigned a drive letter. Thereās an option to assign a path to drives, but less used. With that, one alternative could be to create a new VHD (virtual disk), on the existing C:\ drive and then mount the VHD as D:. However, I just opened a new windows container and the command to create new VHDs is not there, which leads me to believe it is not supported.
If your application cannot read from something else, I think the symlink is the best option. But, I still think it might fail as you donāt have a D:\ drive.