Docker Community Forums

Share and learn in the Docker community.

Cannot mount volume to root folder of visual c++ project in container

Hi All,

I have a visual studio project called filewriter written using c++ 17. program is very simple: it accepts input from the user and writes it to a file test.txt stored in a folder called data which sits right next to the exe.

I built an image using the following Dockerfile:

ARG FROM_IMAGE=mcr.microsoft.com`Preformatted text`/windows/servercore:ltsc2019
FROM ${FROM_IMAGE}

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $verbosePreference='Continue';"]


ARG VS2017=https://aka.ms/vs/15/release/vc_redist.x64.exe
ADD ${VS2017} /vc_redist.exe

COPY \\x64\\Release \\programs

RUN Start-Process -filepath c:\vc_redist.exe -ArgumentList "/install", "/passive", "/norestart", "'/log a.txt'" -PassThru | wait-process

WORKDIR \\programs

ENTRYPOINT ["filewriter.exe"]

And run the container using the following command:

> docker run -it --name myfilewriter -v filewriter_data:c:\programs/data "filewriter:1"

All works well. Problem is I want to add more folders next to the exe (like config for example) however I do not want to create a seperate volume for each folder, therefore I tried mounting the root folder of the exe itself using the following command:

> docker run -it --name myfilewriter -v filewriter_data:c:\programs "filewriter:1"

but I keep getting the following error:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 1cac279217e9c467f8ac0f90661977d78aedd1c540ccc3093434865380f31410 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF75E079D2B: (caller: 00007FF75E02E13A) Exception(4) tid(394) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"filewriter.exe","WorkingDirectory":"C:\\programs","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[50,120]}.

Any help would be greatly appreciated,

Thank you

I’m having a similar issue although I’m doing something pretty simple.

The folder C:\non\non\non exists on my host machine and contains a single text file.

I’ve run the following (and others) and received similar output:

(base) PS C:\Users\Admin> docker run -it  mcr.microsoft.com/windows/servercore:ltsc2019 --mount "source=C:\non\non\non,target=/non"
C:\ProgramData\chocolatey\lib\docker-cli\tools\docker.exe: Error response from daemon: container b1bfb43699c59621061335572e34c84cab21241239d191bf4d724990852b05e0 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF636A09D2B: (caller: 00007FF6369BE13A) Exception(2) tid(39c) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess] 
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"--mount source=C:\\non\\non\\non,target=/non","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[20,146]}.
 
(base) PS C:\Users\Admin> docker run -it  mcr.microsoft.com/windows/servercore:ltsc2019 --mount "source=C:\non\non\non,target=C:\non"
C:\ProgramData\chocolatey\lib\docker-cli\tools\docker.exe: Error response from daemon: container fe7584020cc61ae8df8f25156348f23873a109d2dd04d9401ec9e9be7e74cb8e encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF636A09D2B: (caller: 00007FF6369BE13A) Exception(2) tid(39c) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"--mount source=C:\\non\\non\\non,target=C:\\non","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[20,146]}.
 
(base) PS C:\Users\Admin> docker run -it  mcr.microsoft.com/windows/servercore:ltsc2019 --mount "source=C:/non/non/non,target=C:/non"
C:\ProgramData\chocolatey\lib\docker-cli\tools\docker.exe: Error response from daemon: container 9377639dea0986c45ffeb23b2b127da5bbd438e795e546c7f5bfb48e73a2d794 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF636A09D2B: (caller: 00007FF6369BE13A) Exception(2) tid(39c) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"--mount source=C:/non/non/non,target=C:/non","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[20,146]}.
 
(base) PS C:\Users\Admin> docker run -it  mcr.microsoft.com/windows/servercore:ltsc2019 --mount "source=/C/non/non/non,target=/C/non" 
C:\ProgramData\chocolatey\lib\docker-cli\tools\docker.exe: Error response from daemon: container 239c30349db2fe252e8918f08f6eeab7d5b080ab9ff4593120113ba0055709fd encountered an error during hcsshim::System::CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF636A09D2B: (caller: 00007FF6369BE13A) Exception(2) tid(398) 80070002 The system cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess]
 Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"--mount source=/C/non/non/non,target=/C/non","WorkingDirectory":"C:\\","EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[20,146]}.

I resolved my issue by moving the --mount flag and argument in front of the image. Oops.