Dockerfile在Linux上运行.net核心控制台应用程序(不自包含)

时间:2018-08-17 09:49:28

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

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

如果该文件在exe窗口上有输出(当然是自包含的)。我的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"]

谢谢您的任何建议!

1 个答案:

答案 0 :(得分:2)

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

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

它们也有一个alpine based example的Dockerfile

有关Entrypoint / CMD

的更多信息