Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run container in Docker for Windows: "System cannot find the file specified"

I have a simple c# console app:

static void Main(string[] args)
{
    Console.WriteLine("TESTING!");
    Console.ReadLine();
}

and a DockerFile:

FROM microsoft/windowsservercore
WORKDIR /app
COPY /bin/Debug .
ENTRYPOINT ["dotnet","TestApp.exe"]

I've built an image:

docker build -f dockerfile -t testapp .

Then I try and run it:

docker run testapp

Which gives this error:

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: 
Error response from daemon: container a728cbed9188640df1d6e2f5c4d75f3ae3faef6162ec978575f9a587ed6546eb encountered an error during CreateProcess: 
failure in a Windows system call: 
The system cannot find the file specified. (0x2) extra info:
{"CommandLine":"dotnet TestApp.exe","WorkingDirectory":"C:\\app","CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.

Is it TestApp.exe which it can't find?

like image 800
SturmUndDrang Avatar asked May 24 '18 09:05

SturmUndDrang


1 Answers

First publish the console application. Use the below docker file -

FROM microsoft/windowsservercore
ADD publish/ /
ENTRYPOINT TestApp.exe

The first line in the Dockerfile designates the base image using the FROM instruction. Next, ADD in the file copies the application assets from the publish folder to root folder of the container and last; setting the ENTRYPOINT of the image states that this is the command or application that will run when the container starts.

like image 103
N. Mittal Avatar answered Oct 02 '22 02:10

N. Mittal