我有一个简单的 C# 控制台应用程序:
static void Main(string[] args)
{
Console.WriteLine("TESTING!");
Console.ReadLine();
}
和一个 DockerFile:
FROM microsoft/windowsservercore
WORKDIR /app
COPY /bin/Debug .
ENTRYPOINT ["dotnet","TestApp.exe"]
我构建了一个图像:
docker build -f dockerfile -t testapp .
然后我尝试运行它:
docker run testapp
这给出了这个错误:
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]}.
是找不到的TestApp.exe吗?
最佳答案
首先发布控制台应用程序。 使用下面的 docker 文件 -
FROM microsoft/windowsservercore
ADD publish/ /
ENTRYPOINT TestApp.exe
Dockerfile 的第一行使用 FROM 指令指定基础镜像。接下来,在文件中添加将应用程序 Assets 从发布文件夹复制到容器的根文件夹;设置图像的 ENTRYPOINT 表示这是容器启动时将运行的命令或应用程序。
关于c# - 无法在 Docker for Windows : "System cannot find the file specified" 中运行容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50506121/