.Net Core (3.1) Web API using Docker (Linux container).
I have a Db2 connection via nuget package IBM.Data.DB2.Core-lnx (3.1.0.300).
This Db2 connection works fine when I build and run my Dockerfile independently of VisualStudio 2019.
However, when attempting to debug via VS (fast mode), I run into this exception:
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
My guess is this failure to locate resources is because of the way fast mode debugging works with Docker containers. With the app output copied to a mount, my IBM ENV variables aren't able to find the NuGet clidriver folder. These typically look like this:
ENV DB2_CLI_DRIVER_INSTALL_PATH="/app/clidriver" \
LD_LIBRARY_PATH="/app/clidriver/lib" \
LIBPATH="/app/clidriver/lib" \
PATH=$PATH:"/app/clidriver/bin:/app/clidriver/lib:/app/clidriver/adm"
How can I update these to point to the mounted app contents? Assuming that is the problem...
*Note that I am installing package libxml2-dev in the base of my Dockerfile.
If anyone has a successful strategy for debugging Db2 connections in a Linux container, I would love to hear what you've done. Much thanks in advance.
Running a shell on the debugging container allowed me to see the mounted contents and get the clidriver path. Setting this in the Db2 environment variables fixed the issue:
ENV DB2_CLI_DRIVER_INSTALL_PATH="/app/bin/Debug/netcoreapp3.1/clidriver" \
LD_LIBRARY_PATH="/app/bin/Debug/netcoreapp3.1/clidriver/lib" \
LIBPATH="/app/bin/Debug/netcoreapp3.1/clidriver/lib" \
PATH=$PATH:"/app/bin/Debug/netcoreapp3.1/clidriver/bin:/app/bin/Debug/netcoreapp3.1/clidriver/lib:/app/bin/Debug/netcoreapp3.1/clidriver/adm"