【问题标题】:Docker - dotnet - can't run app from entrypointDocker - dotnet - 无法从入口点运行应用程序
【发布时间】:2018-07-26 11:44:57
【问题描述】:

我的 dockerfile 中的入口点有奇怪的问题。

这是我的 dockerfile:

FROM microsoft/dotnet:latest

WORKDIR /test

ADD . /test

RUN ["dotnet", "restore", "DockerAPI2.sln"]
RUN ["dotnet", "build", "DockerAPI2.sln"]

EXPOSE 4000/tcp

ENTRYPOINT [ "dotnet", "DockerAPI2.dll" ]

当我运行 docker run --name test -d -p 4001:4000 -v "C:\Users\random\docker":"/var/lib" -t test-img:latest 我得到下一个错误:

找不到匹配命令“dotnet-DockerAPI2.dll”的可执行文件

我注意到,出于某种 xy 原因,他在 dotnet 和 DockerAPI2.dll 之间放置了“-”,这是无效的。我想知道这是一个错误还是有什么办法可以解决这个问题?

PS:我正在使用 Linux 容器运行 Docker for Windows,并且我在防火墙中启用了 4001。

【问题讨论】:

  • dotnet build … 是否创建 DockerAPI2.dll/test 中创建,但不是在它的某个子目录中创建?尝试使用绝对完整路径。
  • 是的 dotnet build 创建 dll。我已经弄清楚了。它应该包含 dll 的完整路径,因为 dll 不在 /test 文件夹中,而是在 /test/DockerAPI2/bin/Debug/netcoreapp2.0/

标签: .net docker .net-core command-line-interface


【解决方案1】:

答案很简单。我正在查看 WORKDIR 的目录,即

/测试

,但我需要查看实际 dll 所在的路径,即

/test/DockerAPI2/bin/Debug/netcoreapp2.0/

【讨论】:

  • 这没有意义,你的DockerAPI2.dll应该存在于/testADD . /test之后。但是看起来应该在构建后添加。您的简单 dockerfile 应该用于已构建的应用程序,以便您可以将构建的应用程序复制到映像。
【解决方案2】:

你可以试试 build -o /test 这将重定向输出目录。

【讨论】:

    猜你喜欢
    • 2018-03-15
    • 1970-01-01
    • 1970-01-01
    • 2019-08-07
    • 1970-01-01
    • 2014-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-17
    相关资源
    最近更新 更多