嗨,我有下面的.NET6控制台应用程序的dockerfile

FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["MyProj/MyProj.csproj", "MyProj/"]
RUN dotnet restore "MyProj/MyProj.csproj"
COPY . .
WORKDIR "/src/MyProj"
RUN dotnet build "MyProj.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyProj.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProj.dll"]

我正在使用GitHub Actions CI工具来构建映像并将其部署在kubernet中.我在构建时没有收到任何错误,但当映像运行时,我收到以下错误

You must install or update .NET to run this application.

App: /app/AL.AlphaLinerJob.dll
Architecture: x64
Framework: 'Microsoft.AspNetCore.App', version '6.0.0' (x64)
.NET location: /usr/share/dotnet/

No frameworks were found.

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=6.0.0&arch=x64&rid=debian.11-x64

下面是csproj包

<ItemGroup>
        <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" />
        <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
        <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
        <PackageReference Include="Npgsql" Version="7.0.2" />
        <PackageReference Include="OpenTelemetry" Version="1.3.0-rc.2" />
        <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0" />
        <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.1.0" />
        <PackageReference Include="OpenTelemetry.Exporter.Prometheus" Version="1.3.0-rc.2" />
        <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9" />
        <PackageReference Include="prometheus-net" Version="7.0.0" />
        <PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
        <PackageReference Include="Npgsql" Version="7.0.2" />

我找不到它的根本原因.几天前它工作得很好,突然开始出现这个错误.有人能帮我找出根本原因吗?任何帮助都将不胜感激.

我希望能成功运行该映像.

推荐答案

Change the 1st line:
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
to
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base

Csharp相关问答推荐

使用封装的Span Range.Enumerator时引发IndexOutOfRangeResponse

C#如何克服getter的接口空性

我可以将Expressc操作设置为在另一个Expressc操作完成后自动发生吗?

更新数据库中的对象失败,原因是:Microsoft. EntityFrame Core. GbUpdateConcurrencyResponse'

使用C#中的Shape API从Azure目录获取所有用户

C#相同名称的枚举方法和normal方法,参数类型不同

可为空的泛型属性

在具有主构造函数的类中初始化属性时出现警告

方法从数据表中只 Select 一个条件?

在此系统上已禁用获取正在运行的脚本.&在ASP.NET Core Web API中

ASP.NET核心MVC SqlException:违反主键约束';PK_USER';.无法在对象';数据库中插入重复的密钥.用户';

Docker Container中的HttpRequest后地址不可用

如何将端点(或с匹配请求并判断其路径)添加到BCL?

是否有必要在ASP.NET Core中注册可传递依赖项?

.NET 8 DI GetServices<;对象&>不工作

C#多键字典和TryGetValue

将操作从编辑页重定向到带参数的索引页

VS 2022与VS 2019:如何/为什么创建额外的任务?

如何在GRPC代码First服务的返回类型上使用多态性?

如何在使用属性 Select 器时判断是否可以为空