Dotnet container does not start in kubernetes after adding additional references

9/4/2019

dotnet core container does not start in kubernetes on error 'Back-off restarting failed container'

This always happens after adding additional references to the project.

kubectl logs container does not yield any logs.

When I pull the image locally, and run it via

docker run -it  app:latest . -p 80:80

In the command line it will escape without throwing any errors. Tried adding the verbose logs and it does not throw any errors.

Tried an ubuntu image when launched from visual studio and it runs fine too. Compiling locally it runs fine, and running docker via visual studio the image builds fine.

Also tried building with --no-cache flag with no success

No problems if not running it in a docker container. No errors from the restore, build or publish step.

Running on AKS 1.14.6

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine AS build
WORKDIR /src
COPY ["Company.Reference.ApplicationHub/Company.Reference.ApplicationHub.csproj", "Company.Reference.ApplicationHub/"]
COPY ["Core/Providers/Company.Reference.DeliveryPlanner.Provider/Company.Reference.DeliveryPlanner.Provider.csproj", "Core/Providers/Company.Reference.DeliveryPlanner.Provider/"]
COPY ["Core/Providers/Company.Reference.Ups/Company.Reference.Ups.csproj", "Core/Providers/Company.Reference.Ups/"]
COPY ["Common/Company.Reference.Common/Company.Reference.Common.csproj", "Common/Company.Reference.Common/"]
COPY ["Core/Providers/Company.Reference.Tracking.Provider/Company.Reference.Tracking.Provider.csproj", "Core/Providers/Company.Reference.Tracking.Provider/"]
COPY ["Core/Providers/Company.Reference.Authentication.Provider/Company.Reference.Authentication.Provider.csproj", "Core/Providers/Company.Reference.Authentication.Provider/"]
COPY ["Core/Providers/Company.Reference.Locator.Provider/LocatorProvider/Company.Reference.Locator.Provider.csproj", "Core/Providers/Company.Reference.Locator.Provider/LocatorProvider/"]
COPY ["Core/Providers/Company.Reference.Geolocate.Provider/Company.Reference.Geolocate.Provider.csproj", "Core/Providers/Company.Reference.Geolocate.Provider/"]
COPY ["Core/Repository/Company.Reference.Repository/Company.Reference.Repository.csproj", "Core/Repository/Company.Reference.Repository/"]
COPY ["Core/Providers/Company.Reference.MyChoice.Provider/Company.Reference.MyChoice.Provider.csproj", "Core/Providers/Company.Reference.MyChoice.Provider/"]
COPY ["Core/Company.Reference.Infrastructure/Company.Reference.Infrastructure.csproj", "Core/Company.Reference.Infrastructure/"]
COPY ["Core/Providers/Company.Reference.EligibilityOptions.Provider/Company.Reference.EligibilityOptions.Provider.csproj", "Core/Providers/Company.Reference.EligibilityOptions.Provider/"]
RUN dotnet restore "Company.Reference.ApplicationHub/Company.Reference.ApplicationHub.csproj"
COPY . .
WORKDIR "/src/Company.Reference.ApplicationHub"
RUN dotnet build "Company.Reference.ApplicationHub.csproj" -c Release -o /app -v diag

FROM build AS publish
RUN dotnet publish "Company.Reference.ApplicationHub.csproj" -c Release -o /app -v diag

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

It used to run fine before adding the additional references. Could it be from caching somewhere?

-- user2172398
.net
.net-core
azure-aks
docker
kubernetes

1 Answer

9/5/2019

Are you sure you are running the same image from docker as from Kubernetes? 'cause once the image is build, the content (and thus your dependencies) are untouched.

Try rebuilding the image using a different tag (using `latest' is never a good idea):

docker build . -t app:v1

Then use app:v1 as your image in Kubernetes

-- Sam
Source: StackOverflow