在基于.NETCore 3.0预览版的Docker容器中运行.NetCore App

时间:2019-03-25 13:25:55

标签: docker .net-core docker-compose console-application

在运行我的应用程序后,代码退出 150

  

输出:调试


You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '3.0.0-preview3-27503-5' was not found.
  - Check application dependencies and target a framework version installed at:
      /usr/share/dotnet/
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      3.0.0-preview-27324-5 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  - Installing .NET Core prerequisites might help resolve this problem:
      https://go.microsoft.com/fwlink/?linkid=2063370
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[31] dotnet' has exited with code 150 (0x96).
The program 'dotnet' has exited with code 150 (0x96).

1 个答案:

答案 0 :(得分:0)

如果您在 Docker Container 中运行应用程序时遇到问题,请确保为您的 .NET Core SDK 使用正确的 Image Dockerfile

中指定

对于 .NET Core SDK 3.0.100-preview3-010431

Dockerfile 创建不正确。 您可以在 hub.docker.com

中查看各种 SDK Dockerfile 示例。
  

https://hub.docker.com/_/microsoft-dotnet-core-sdk/?tab=description

示例:

FROM buildpack-deps:stretch-scm

# Install .NET CLI dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        libc6 \
        libgcc1 \
        libgssapi-krb5-2 \
        libicu57 \
        libssl1.1 \
        libstdc++6 \
        zlib1g \
    && rm -rf /var/lib/apt/lists/*

# Install .NET Core SDK
ENV DOTNET_SDK_VERSION 3.0.100-preview3-010431

...