I followed the instructions I have found online and this is my dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /source
# copy csproj and restore as distinct layers
COPY *.csproj .
RUN dotnet restore
# copy and publish app and libraries
COPY . .
RUN dotnet publish -c release -o /app --no-restore
# final stage/image
FROM mcr.microsoft.com/dotnet/runtime:5.0
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["my-app"]
I also have a .dockerignore because I was getting dir length exceeded errors:
Dockerfile
[b|B]in
[O|o]bj
When I try and run it I get this error stating that aspnetcore was not found:
It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '5.0.0' was not found.
- No frameworks were found.
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=5.0.0&arch=x64&rid=debian.10-x64
Am I doing something wrong here?
3
Answers
Usually entry point looks like
ENTRYPOINT ["dotnet", "my-app.dll"]
, not justENTRYPOINT ["my-app"]
.Except answer mentioned by @mtkachenko with incorrect entrypoint, you have aspnet app thus you need aspnet librariers. Instead of runtime image
mcr.microsoft.com/dotnet/runtime:5.0
usemcr.microsoft.com/dotnet/aspnet:5.0
.Updating dockerfile to use
FROM mcr.microsoft.com/dotnet/sdk:5.0
instead ofFROM mcr.microsoft.com/dotnet/runtime:5.0
resolved the issue for me.