This is my docker compose file:
version: '3.4'
networks:
demonetwork:
services:
demoappdb:
container_name: app-db
image: mcr.microsoft.com/mssql/server:2019-latest
ports:
- 8002:1433
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=password@12345#
networks:
- demonetwork
lightcleanarchitecturewebapi:
container_name: lca-app
image: ${DOCKER_REGISTRY-}lightcleanarchitecturewebapi
build:
context: .
dockerfile: src/Web/Dockerfile
ports:
- 8081:8081
- 8080:8080
depends_on:
- demoappdb
environment:
- DB_HOST=demoappdb
- DB_NAME=DemoBlazorApp
- DB_SA_PASSWORD=password@12345#
networks:
- demonetwork
When I want to run my migration to create a database I get this error:
2024-01-12 16:28:38 Cannot load library libgssapi_krb5.so.2
2024-01-12 16:28:38 Error: libgssapi_krb5.so.2: cannot open shared object file: No such file or directory
Error happened on context.Database.Migrate():
using (var serviceScope = app.ApplicationServices.CreateScope())
{
var context = serviceScope.ServiceProvider.GetRequiredService<T>();
context.Database.Migrate();
}
This is my Docker file:
# Use a Debian-based image with ASP.NET runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Web/LightCleanArchitecture.WebApi.csproj", "src/Web/"]
COPY ["src/Application/LightCleanArchitecture.Application.csproj", "src/Application/"]
COPY ["src/Domain/LightCleanArchitecture.Domain.csproj", "src/Domain/"]
COPY ["src/Infrastructure/LightCleanArchitecture.Infrastructure.csproj", "src/Infrastructure/"]
RUN dotnet restore "./src/Web/./LightCleanArchitecture.WebApi.csproj"
COPY . .
WORKDIR "/src/src/Web"
RUN dotnet build "./LightCleanArchitecture.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./LightCleanArchitecture.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "LightCleanArchitecture.WebApi.dll"]
This problem only happens on ASP.NET Core 8, it's working properly for .NET 6.
I think I have to install libgssapi_krb5.so.2
on the docker image that I created, but I could not find how to do it.
If you have any experiences in this case, please share it.
as I understand, this error caused my program to crash, but I could not get any exception error in the catch part.
2024-01-12 16:28:38 Cannot load library libgssapi_krb5.so.2
2024-01-12 16:28:38 Error: libgssapi_krb5.so.2: cannot open shared Object file: No such file or directory
what did I do? I changed my base image from aspnet:8.0 to aspnet:8.0-jammy-amd64, After this change, I could get an error message in the catch part.
That error was about my connection string, I had to add this option "Trusted_Connection = false" to fix this issue.