View Only

Unable to load shared library 'libdb2.so'

  • 1.  Unable to load shared library 'libdb2.so'

    Posted Thu December 29, 2022 01:49 PM

    We are working on deploying asp .net core api in google cloud run serverless container, as our api has dependency with db2 drivers so we have made following changes in dockerfile, and to download DB2 Drivers Package we are using this version of nuget package reference - "Net5.IBM.Data.Db2-lnx" Version="", but our API is throwing below mentioned error.

    Unable to load shared library 'libdb2.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdb2.so: cannot open shared object file: No such file or directory

    I  already checked that running same image in my local, clidriver is only in 1 path i.e. /app/clidriver

    Below command i run to find clidriver path PS C:\WINDOWS> docker exec -it 81c1b8219edc bash root@81c1b8219edc:/app# cd .. root@81c1b8219edc:/# find / -name clidriver /app/clidriver

    Following is our docker file changes.

    FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
    RUN apt-get update -y && apt-get install jq dos2unix curl -y
    WORKDIR /app
    EXPOSE 80
    EXPOSE 443
    RUN chmod -R 777 /app
    ENV DB2_CLI_DRIVER_INSTALL_PATH=/app/clidriver
    ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/clidriver/lib
    ENV LIBPATH=/app/clidriver/lib
    ENV PATH=$PATH:/app/clidriver/bin:/app/clidriver/lib
    FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
    WORKDIR /src
    COPY ["SourceCode/SomeAPI.WebApi/SomeAPI.WebApi.csproj", "SourceCode/SomeAPI.WebApi/"]
    RUN dotnet restore "SourceCode/SomeAPI.WebApi/SomeAPI.WebApi.csproj"
    COPY . .
    WORKDIR "/src/SourceCode/SomeAPI.WebApi"
    RUN dotnet build "SomeAPI.WebApi.csproj" -c Release -o /app/build
    FROM build AS publish
    RUN dotnet publish "SomeAPI.WebApi.csproj" -c Release -o /app/publish
    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app/publish .
    ENTRYPOINT ["dotnet", "SomeAPI.WebApi.dll"]

    Dushyant Padhya