【问题标题】:Dockerfile to run .net core console app on Linux (which is not self contained)Dockerfile 在 Linux 上运行 .net 核心控制台应用程序(不是自包含的)
【发布时间】:2019-01-24 08:08:36
【问题描述】:

我有一个 .net Core 2.1 控制台应用程序,我想将它构建到一个将部署到 Linux (Alpine) 的 docker 容器中。

如果这在 exe 的 Windows 上有输出(当然是独立的)。我的 docker 文件可能如下所示:

COPY  /output/ /bin/
CMD ["/bin/sample.exe"]

因为我想让它成为一个可移植的应用程序(并且已经在 Linux 机器上安装了 .net Core Runtime),所以我的 docker 文件应该如下所示:

FROM microsoft/dotnet:2.1-runtime

COPY  /output/ /bin/
CMD ["dotnet", "/bin/sample.dll"]

提前感谢您的任何建议!

【问题讨论】:

    标签: linux docker .net-core console-application dockerfile


    【解决方案1】:

    是的,Microsoft 有一个 dotnet docker samples 存储库。他们的 Dockerfile 如下所示:

    FROM microsoft/dotnet:2.1-runtime
    COPY /output /bin/
    ENTRYPOINT ["dotnet", "/bin/dotnetapp.dll"]
    

    他们还有一个 Dockerfile 的alpine based example

    欲了解更多信息Entrypoint / CMD

    【讨论】:

      猜你喜欢
      • 2021-02-03
      • 1970-01-01
      • 2018-05-14
      • 1970-01-01
      • 1970-01-01
      • 2021-12-05
      • 1970-01-01
      • 2019-09-26
      • 1970-01-01
      相关资源
      最近更新 更多