gpt4 book ai didi

c# - 为什么 dotnet 5 docker 容器在运行时失败?

转载 作者:行者123 更新时间:2023-12-01 23:25:48 25 4
gpt4 key购买 nike

我有一个 dotnet5 控制台应用程序,它位于解决方案中并且依赖于其他同级项目。我使用 visual studio 工具创建了 Docker 文件,这是 Docker 文件:

FROM mcr.microsoft.com/dotnet/runtime:5.0-buster-slim AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["src/MyProject/MyProject.Launcher/MyProject.Launcher.csproj", "src/MyProject/MyProject.Launcher/"]
COPY ["src/MyProject/MyProject.DataAccess/MyProject.DataAcess.csproj", "src/MyProject/MyProject.DataAccess/"]
COPY ["src/MyProject/MyProject.Service/MyProject.Service.csproj", "src/MyProject/MyProject.Service/]
COPY ["src/Domain/MyProject.Domain.Model/MyProject.Domain.Model.csproj", "src/Domain/MyProject.Domain.Model/"]
RUN dotnet restore "src/MyProject/MyProject.Launcher/MyProject.Launcher.csproj"
COPY . .
WORKDIR "/src/src/MyProject/MyProject.Launcher"
RUN dotnet build "MyProject.Launcher.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyProject.Launcher.csproj" -c Release -o /app/publish

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

构建镜像没问题,它正常添加到我的本地镜像注册表中,但是当我尝试运行这个镜像并创建一个容器时,我收到这个错误:

It was not possible to find any compatible framework version Theframework 'Microsoft.AspNetCore.App', version '5.0.0' was not found.

  • No frameworks were found.

You can resolve the problem by installing the specified frameworkand/or SDK.

最佳答案

将其用作您的基础图像:

来自 mcr.microsoft.com/dotnet/aspnet:5.0.0-buster-slim AS base

关于c# - 为什么 dotnet 5 docker 容器在运行时失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67270472/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com