c# - 无法在 Docker for Windows : "System cannot find the file specified" 中运行容器

标签 c# docker docker-for-windows

我有一个简单的 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/

相关文章:

c# - 未从分区获取所有结果

docker - 带有 Docker Compose 和 django 的 Azure 应用服务

docker - docker(1.12) 容器的健康检查命令(不在 Dockerfile 中!)

c# - 获取数组中元素索引的快速方法是什么?

c# - 从一个盒子建立多个 TCP 连接以进行压力测试

c# - 在 C# 中继承泛型

docker - Docker Compose 中外部卷和默认卷之间的区别?

docker - 在 docker 中附加卷后找不到模块

.net - 如何将 NuGet 包添加到 Dockerfile 构建步骤?

docker - 使用Docker for Windows备份,还原或迁移数据卷