'Docker run doesn't start the container

I have created a dotnet webapi service using dotnet core 5, built a docker image with the below Dockerfile and while running it get the below error message:

Could not execute because the application was not found or a compatible .NET SDK is not installed.

Possible reasons for this include:

  * You intended to execute a .NET program:

      The application 'PlatformService.dll' does not exist.

  * You intended to execute a .NET SDK command:

      It was not possible to find any installed .NET SDKs.

      Install a .NET SDK from:

        https://aka.ms/dotnet-download

DockerFile:

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /app

COPY *.csproj ./
RUN dotnet restore

COPY . ./
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:5.0

WORKDIR /app

COPY --from=build-env /app/out .

ENTRYPOINT [ "dotnet", "PlatformService.dll" ]

Can some one point out what exactly is missing here to run my image. BTW I am running this on Windows 10 machine.



Solution 1:[1]

This error will happen if the casing of the DLL name you're targeting in your Dockerfile doesn't match the casing of the file that exists on disk (this is only true for Linux). Be sure that ENTRYPOINT [ "dotnet", "PlatformService.dll" ] uses a DLL name that matches the casing of the actual file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matt Thalman