docker run:由于找不到指定的命令或文件而无法执行

问题描述 投票:0回答:1

我为.net核心控制台应用制作了一个docker文件:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1
LABEL author="some name"
LABEL description="some description"
ENTRYPOINT [ "dotnet", "L1_1_Console.dll" ]

并从中创建一个名为“ labo1_1_console_image”的图像]

当我尝试使用此命令运行此图像时:

docker run --rm -it labo1_1_console_image

我收到此错误:

Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-L1_1_Console.dll does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

我认为问题是第二个问题(不确定),但我不知道如何解决此问题,我的L1_1_Console.dll文件分别对应于docker文件位置/bin/Release/netcoreapp3.1(我也有一个发布文件夹在这里有相同的文件)

c# docker .net-core console-application
1个回答
0
投票

将您的Dockerfile更改为

FROM mcr.microsoft.com/dotnet/core/sdk:3.1
LABEL author="some name"
LABEL description="some description"
ADD bin/Release/netcoreapp3.1/L1_1_Console.dll L1_1_Console.dll
ENTRYPOINT [ "dotnet", "L1_1_Console.dll" ]

[入口点只能看到docker映像中的文件(除非安装了外部卷),所以您需要先将dll文件添加到映像中,然后才能运行它。

© www.soinside.com 2019 - 2024. All rights reserved.