代码之家  ›  专栏  ›  技术社区  ›  Rob

Dockerfile在Linux上运行.net core控制台应用程序(它不是自包含的)

  •  1
  • Rob  · 技术社区  · 8 年前

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

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

    因为我想让它成为一个可移植的应用程序(并且已经在Linux框上有了.net Core运行时),如果我的docker文件是这样的:

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

    谢谢你事先的建议!

    1 回复  |  直到 8 年前
        1
  •  4
  •   mschuurmans    8 年前

    是的,微软有一个dotnet docker samples

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

    他们也有 alpine based example 可停靠文件的

    Entrypoint / CMD