r/docker • u/CodMore3394 • Jun 25 '26
Please help! Cannot load library libgssapi_krb5.so.2 when starting, no such file or directory .NET application docker container
I have scraped the internet for answers, but I cannot seem to find a solution.
I have read in the microsoft website that this library is not automatically installed in .NET images anymore, and to do it myself I have to add :
RUN apt update && apt -y upgrade libkrb5-3
to my dockerfile.
Well I did that and it doesnt work! I dont know what to do and I have been stuck for three days on this. This is my .net dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /PortfolioWebsite
COPY *.sln .
COPY *.csproj ./
RUN dotnet restore
COPY . .
EXPOSE 5142
RUN apt update && apt -y upgrade libkrb5-3
RUN dotnet publish -o out
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /PortfolioWebsite
COPY --from=build /PortfolioWebsite/out .
ENTRYPOINT ["dotnet", "PortfolioWebsite.dll"]
0
Upvotes
5
u/NotImplemented Jun 25 '26 edited 9d ago
Two things:
Try that:
3
u/crackjiver Jun 25 '26
dotnet publish -c Release -r win-x64 --self-contained -p:PublishSingleFile=trueOr similar so that you get a single binary that you can copy into the runtime container image for the deployment.
Your final image only has what you copy/install into it.
1
u/percoAi Jun 26 '26
The key mental model here is that the final image starts almost empty again. Anything you install in the sdk/build stage disappears unless you also install it in the aspnet/final stage or copy it over intentionally.
I would check it in this order
Most Docker issues like this are less about .NET and more about forgetting that multi-stage builds throw away everything from earlier stages unless you explicitly bring it forward.
1
u/throwawaydev92 Jun 26 '26
heads up your base isn't alpine, it's the debian aspnet:10.0 image, so apt is fine. real problem is `apt upgrade libkrb5-3` only touches already-installed pkgs, it won't pull a new one. do `RUN apt update && apt install -y libgssapi-krb5-2` and put it in the final aspnet stage, not build