I am very new to docker. And I am trying to dockerize a helloworld API. But when I tried to docker run the image, I got this error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container f891d7fc7af6e1183256043e6105fc87e25c6959d9745cc972b42c7b2e6f5a06 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: vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(168)\vmcomputeagent.exe!00007FF683797B25: (caller: 00007FF68377A312) Exception(4) tid(108) 80070002 The system cannot find the file specified. CallContext:[\Bridge_ProcessMessage\ComputeSystemManager_ExecuteProcess\VmHostedContainer_ExecuteProcess] Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"dotnet HelloWorldDocker.dll","WorkingDirectory":"C:\app\bin","Environment":{"COMPLUS_NGenProtectedProcess_FeatureEnabled":"0","ROSLYN_COMPILER_LOCATION":"c:\\RoslynCompilers\\tools"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.
I have a simple asp.net api. And I have it published to the same folder ./publish
And here is my docker file
FROM microsoft/aspnet:4.7.1-windowsservercore-1709
WORKDIR /app
COPY ./publish .
WORKDIR bin
RUN ls
ENTRYPOINT ["dotnet", "HelloWorldDocker.dll"]
ls
shows that the HelloWorldDocker.dll
is in the directory ./bin (app/bin)
. IDK what is wrong here...
This line COPY ./publish .
will copy all publish files into your current work directory. The bin folder that contains your DLL now lives here: /app/bin/{your dll}
.
It is not necessary to then change the work dir to bin like you did; instead, you could either leave your work dir alone (stay in /app) and specify your entrypoint as:ENTRYPOINT ["dotnet", "./bin/HelloWorldDocker.dll"]
-OR-
You could set your WORKDIR to /app/bin
and specify your entrypoint as you already did: ENTRYPOINT ["dotnet", "HelloWorldDocker.dll"]
The main thing you need to keep in mind is where the files are in relation to your workdir, which you can manage by changing your workdir as well as copying files, as you did by copying all publish files into /app
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With