How do I connect to DB2 from a docker container using ASP.Net Core?

2

I am attempting to connect to a DB2 server (on prem) from a Windows based Docker container. It is currently using the IMB.Data.DB2.Core nuget package (latest). The docker file is just the auto-generated file that Visual Studio 2019 creates with no changes.

The project is set to 64-bit and there are no errors or warnings on build.

I have searched everywhere for how to make this work and have been unable to find this problem elsewhere. I suspect that the issue is due to my lack of Docker knowledge and DB2 needing something particular setup within the container. I have verified that the files are being copied (locally at least) when building so they should be there.

Dockerfile:

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

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-1809 AS build  
WORKDIR /src  
COPY ["DockerDb2Test.csproj", ""]  
RUN dotnet restore "DockerDb2Test.csproj"  
COPY . .  
WORKDIR "/src/"  
RUN dotnet build "DockerDb2Test.csproj" -c Release -o /app  

FROM build AS publish  
RUN dotnet publish "DockerDb2Test.csproj" -c Release -o /app  

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

There's a default values controller that always works however when calling any code that attempts to access DB2, the following exception method is returned:

Unable to load DLL 'db2app64.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E

)

docker
.net-core
db2
dockerfile
asp.net-core-webapi
asked on Stack Overflow Jun 21, 2019 by r_n_gomez • edited Jun 21, 2019 by mao

3 Answers

2

I was able to get it to work by adding the following to the Dockerfile above the ENTRYPOINT:

ENV LD_LIBRARY_PATH="/app/clidriver/lib/" Env PATH=$PATH:"/app/clidriver/bin:/app/clidriver/lib" RUN apt-get update; \ apt-get install -y libxml2-dev;

Please note that I switched to a Linux container: sdk:2.2.300-stretch

answered on Stack Overflow Jun 24, 2019 by r_n_gomez
0

Please follow the post .Net Core Linux - Docker - Local debugging with DB2

I have included the LD_LIBRARY_PATH variable to be added as a solution. Thanks.

answered on Stack Overflow May 10, 2021 by Vishwajeet Sawant
-1

Need to install one of the IBM Data Server Client Packages that ship IBM.Data.DB2.dll and other DB2 .NET assemblies/resources/managed and unmanaged dependencies.

The recommended thin client is IBM Data Server Driver Package, 10.5 Fixpack 5 link for the latest IBM Data Server Client Packages is:

http://www-01.ibm.com/support/docview.wss?uid=swg24038920


User contributions licensed under CC BY-SA 3.0