docker 运行: 无法执行,因为找不到指定的命令或文件

docker run: Could not execute because the specified command or file was not found

我为 .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(我这里也有一个包含相同文件的发布文件夹)

更新:

我将 docker 文件更改为:

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

将您的 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 文件添加到图像才能 运行 它.