title: Unable to load DLL 'libdb2.so' when establishing a DB2 connection with .net core in docker
body: <p>How do I make the libdb2.so file visible to the DB2 package? I have verified that the package works in Ubuntu, but I cannot make it work inside Docker.</p>
  
  <p>Dockerfile</p>
  
  <pre><code>FROM microsoft/aspnetcore:1.0
  #assume the built app is in /app from the build so that the entrypoint command runs in the correct path
  WORKDIR /app
  
  #need to specify db2 driver lib
  ENV LD_LIBRARY_PATH="/app/db2Lib"
  
  #move all the source code in local directory ./app into the container directory /app
  COPY ./app .
  
  RUN mkdir -p db2Lib
  
  ADD db2Lib db2Lib/
  ADD ./runImage.sh .
  
  
  RUN chmod -R a+wrx runImage.sh
  
  EXPOSE 8080
  ENTRYPOINT ["./runImage.sh"]
  </code></pre>
  
  <p>runImage.sh</p>
  
  <pre><code>#!/bin/bash
  ls $LD_LIBRARY_PATH
  echo $LD_LIBRARY_PATH
  dotnet app.dll
  </code></pre>
  
  <p>Upon running the image, I get the following prints in the console</p>
  
  <pre><code>#from ls $LD_LIBRARY_PATH
  icc 
  libDB2xml4c.so
  libDB2xml4c.so.58
  libDB2xml4c.so.58.0
  libdb2.so
  libdb2.so.1
  libdb2clixml4c.so
  libdb2clixml4c.so.1
  libdb2o.so
  libdb2o.so.1
  #from echo $LD_LIBRARY_PATH
  /app/db2Lib
  </code></pre>
  
  <p>but when my application runs, I get the following error </p>
  
  <blockquote>
    <p>Unhandled Exception: System.DllNotFoundException: Unable to load DLL
    'libdb2.so': The specified module could not be found.</p>
  </blockquote>
  
  <p>As you can see, the LD_LIBRARY_PATH environment variable properly points to the correct directory as the documentation instructs at <a href="https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/Instructions_for_downloading_and_using_DB2_NET_Core_provider_package?lang=en" rel="nofollow noreferrer">https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/Instructions_for_downloading_and_using_DB2_NET_Core_provider_package?lang=en</a>.</p>
  
  <p>To double check that the environment variable is being set, I do</p>
  
  <pre><code>Console.WriteLine(Configuration["LD_LIBRARY_PATH"]);
  </code></pre>
  
  <p>which indeed prints </p>
  
  <blockquote>
    <p>/app/db2Lib</p>
  </blockquote>