Search code examples
c#dockerasp.net-corecentos

centos 8 in the docker build net core 5.0 error message NET SDK is not installed


I Project MVCVue add a folder build path home/paul/Downloads/MVCVue/App/bin/De
#Dokerfile#

ROM mcr.microsoft.com/dotnet/aspnet:5.0-focal AS base
WORKDIR /app
EXPOSE 5000

ENV ASPNETCORE_URLS=http://+:5000
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app

USER appuser

FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build
WORKDIR /src
COPY ["MVCVue.csproj", "./"]
COPY . .

FROM base AS final
WORKDIR /app
ENTRYPOINT ["dotnet", "MVCVue.dll"]

my docker images
#docker images#

Step 13/13 : ENTRYPOINT ["dotnet", "MVCVue.dll"]
 ---> Running in cc2865b2290a
Removing intermediate container cc2865b2290a
 ---> 2f79dc5fec19
Successfully built 2f79dc5fec19
Successfully tagged netcore:v
[root@localhost De]# docker images
REPOSITORY                        TAG         IMAGE ID       CREATED              SIZE
netcore                           v           2f79dc5fec19   About a minute ago   215MB
<none>                            <none>      83feaa33c847   About a minute ago   646MB
mcr.microsoft.com/dotnet/sdk      5.0-focal   939156dd4acc   12 days ago          646MB
mcr.microsoft.com/dotnet/aspnet   5.0-focal   063dc45e41e8   12 days ago          213MB

I have SDK 5.0 I don't know what was missed but Tell me to err NET SDK is not installed

#error message#

[root@localhost De]# docker run netcore:v
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 'MVCVue.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


Solution

  • You don't build your application in your Dockerfile, so that's why there's nothing to execute.

    Try changing your Dockerfile to

    FROM mcr.microsoft.com/dotnet/aspnet:5.0-focal AS base
    WORKDIR /app
    EXPOSE 5000
    
    ENV ASPNETCORE_URLS=http://+:5000
    RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
    
    USER appuser
    
    FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build
    WORKDIR /src
    COPY ["MVCVue.csproj", "./"]
    RUN dotnet restore
    COPY . .
    RUN dotnet publish -c Release -o out
    
    FROM base AS final
    WORKDIR /app
    COPY --from=build /src/out .
    ENTRYPOINT ["dotnet", "MVCVue.dll"]