我有一个这样的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 ["Project/Project.csproj", "Project/"]
COPY ["Reference/Reference.csproj", "Reference/"]
RUN dotnet restore "Project/Project.csproj"
RUN dotnet restore "Reference/Reference.csproj"
COPY . .
WORKDIR "/src/Project"
RUN dotnet build "Project.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Project.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Project.dll"]
但是当我想用docker build -f Dockerfile -t mytag . && docker run --name myproject mytag
构建并运行它时,我在构建后得到一个错误:
You must install or update .NET to run this application.
2022-11-09T15:48:22.642099385Z
2022-11-09T15:48:22.642104961Z App: /app/Project.dll
2022-11-09T15:48:22.642108153Z Architecture: x64
2022-11-09T15:48:22.642111392Z Framework: 'Microsoft.AspNetCore.App', version '6.0.0' (x64)
2022-11-09T15:48:22.642115860Z .NET location: /usr/share/dotnet/
2022-11-09T15:48:22.642119020Z
2022-11-09T15:48:22.642122144Z No frameworks were found.
为什么会这样?
1条答案
按热度按时间tzcvj98z1#
runtime
映像适用于控制台应用程序。您的应用程序是ASP.NET应用程序,因此应改用aspnet
运行时映像。替换与