Error “system cannot find the file specified” when

2019-07-25 14:37发布

问题:

I cannot get Windows containers to start when either mount or volume is specified on the run command. Containers run fine without the specification. I've also tried explicitly creating a volume (Docker managed) bit still get the cannot find file error.

Below is one of many variations I've tried using a basic nanoserver image. The source folder exists on the host and I've given full control permissions on the folder to everyone for troubleshooting.

docker run -it --rm --name nanoserver -d microsoft/nanoserver --mount "source=C:\HostDataForDockerContainer,target=C:\ContainerData"

The error text:

docker: Error response from daemon: 
container 9f0b1d6ef217986b8c0225fb38e96cbc51db2d3eff79591e9f3d5288f86f2851 encountered an error during CreateProcess: 
failure in a Windows system call: 
The system cannot find the file specified. (0x2) extra info: 
{"CommandLine":"--mount source=C:\\HostDataForDockerContainer,target=C:\\ContainerData","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[30,120]}.

I recently upgraded to the latest Docker for Windows version but I had not tried mounting volumes previously so I don't know if this is a regression issue with this Docker version or something isolated to my host configuration or Docker usage.

The mount spec looks correct to me according to the doc but I'd appreciate if someone can confirm.

My host machine is Windows 10 Pro running Docker Community Edition version 18.03.1-ce-win64 (17438).

EDIT:

As @JonathonReinhart suggested, I tried reordering the mount option as an earlier argument and got the same error, although the extra info in the error message suggests not all the arguments were recognized in every case. Here are the permutations I tried:

docker run --mount "type=bind,source=C:\HostDataForDockerContainer,target=C:\ContainerData" -it -d microsoft/nanoserver --rm --name nanoserver
docker: Error response from daemon: 
container f91312790b941a48cea49bb68d939acb648d85a078b30f0a5b74e9e7bae32147 encountered an error during CreateProcess: 
failure in a Windows system call: 
The system cannot find the file specified. (0x2) extra info: 
{"CommandLine":"--rm --name nanoserver","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[57,120]}.

docker run -it --mount "type=bind,source=C:\HostDataForDockerContainer,target=C:\ContainerData" -d microsoft/nanoserver --rm --name nanoserver
docker: Error response from daemon: 
container 43fbe911dcd275f55636bd97e4b3498f7c71e265cdda6cb85dacf19bdc8464f1 encountered an error during CreateProcess: 
failure in a Windows system call: 
The system cannot find the file specified. (0x2) extra info: 
{"CommandLine":"--rm --name nanoserver","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[57,120]}.

docker run -it --rm --name nanoserver -d microsoft/nanoserver --mount "type=bind,source=C:\HostDataForDockerContainer,target=C:\ContainerData"
docker: Error response from daemon: 
container 14e81f566d2ad45d3103b2e292924eab2b0490f992ae9deaf750b99c25d1ca77 encountered an error during CreateProcess: 
failure in a Windows system call: 
The system cannot find the file specified. (0x2) extra info: 
{"CommandLine":"--mount type=bind,source=C:\\HostDataForDockerContainer,target=C:\\ContainerData","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[57,120]}.

docker run -it -d microsoft/nanoserver --mount "type=bind,source=C:\HostDataForDockerContainer,target=C:\ContainerData" --rm --name nanoserver
docker: Error response from daemon: 
container 20cf5692417a9d455dd4a05ff77516dc4f17d4b0d9cc8c37d29dc842b82f5007 encountered an error during CreateProcess: 
failure in a Windows system call: 
The system cannot find the file specified. (0x2) extra info: 
{"CommandLine":"--mount type=bind,source=C:\\HostDataForDockerContainer,target=C:\\ContainerData --rm --name nanoserver","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[57,120]}.

docker run -it -d microsoft/nanoserver --rm --mount "type=bind,source=C:\HostDataForDockerContainer,target=C:\ContainerData" --name nanoserver
docker: Error response from daemon: 
container fba579fa3d788f4890b0c1523495742b689513150800e1b19f6f70f2a0e49819 encountered an error during CreateProcess: 
failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: 
{"CommandLine":"--rm --mount type=bind,source=C:\\HostDataForDockerContainer,target=C:\\ContainerData --name nanoserver","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[57,120]}.

docker run -it -d microsoft/nanoserver --rm --name nanoserver --mount "type=bind,source=C:\HostDataForDockerContainer,target=C:\ContainerData"
docker: Error response from daemon: 
container 76b1117b65e6e345284c083af39fa8a627369fb5518fe89ed2519aa224f82d0a encountered an error during CreateProcess: 
failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: 
{"CommandLine":"--rm --name nanoserver --mount type=bind,source=C:\\HostDataForDockerContainer,target=C:\\ContainerData","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[57,120]}.