Docker Error UnixODBC - [01000] [unixODBC][Driver Manager] Can't open lib 'XY' : file not found

59 Views Asked by At

i am trying to install a driver from UnixODBC in docker to be able to connect to HANA Express from R.

Locally on my mac it is sufficient if I use

  1. install unixodbc via homebrew
  2. install odbc package via install.packages("odbc") in an R terminal
  3. download the SAP HANA client and reference the .dylib file in the odbcinst.ini config file as follows:

[HDBODBC] Description = HANA ODBC driver Driver = /Applications/sap/hdbclient/libodbcHDB.dylib

I try to download exactly the same in my dockerfile without the SAP HANA client, because I copy the "libodbcHDB.dylib" file directly into it. My Dockerfile looks like this:

#Use Python 3.10 as the base image FROM python:3.10

#Set non-interactive installation to avoid prompts ENV DEBIAN_FRONTEND=noninteractive

#Update and install dependencies required for R and other tools RUN apt-get update && apt-get install -y
software-properties-common
apt-transport-https
wget
curl
libcurl4-openssl-dev
libssl-dev
libxml2-dev
libpq-dev
libnode-dev
libmpfr-dev

#Add CRAN repository to get the specific R version RUN wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc RUN add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

#Install R and verify the version RUN apt-get update && apt-get install -y r-base r-base-dev && R --version

#Install odbc driver RUN apt-get update && apt-get install -y unixodbc-dev

#Install specific R packages RUN R -e "install.packages(c('causaleffect', 'dagitty', 'RPostgreSQL', 'igraph'), dependencies=TRUE, repos='https://cran.r-project.org/', lib='/usr/lib/R/site-library')" > install_log.txt 2>&1

#Install sepecific R packages which require specific versions RUN R -e "install.packages('https://cran.r-project.org/src/contrib/Archive/bnlearn/bnlearn_4.9.tar.gz', repos=NULL, type='source', lib='/usr/lib/R/site-library')" RUN R -e "install.packages('https://cran.r-project.org/src/contrib/Archive/jsonlite/jsonlite_1.8.7.tar.gz', repos=NULL, type='source', lib='/usr/lib/R/site-library')" RUN R -e "install.packages('https://cran.r-project.org/src/contrib/Archive/data.table/data.table_1.14.8.tar.gz', repos=NULL, type='source', lib='/usr/lib/R/site-library')" RUN R -e "install.packages(c('odbc'), dependencies=TRUE, repos='https://cran.r-project.org/', lib='/usr/lib/R/site-library')" > odbc_r_package_log.txt 2>&1

ENV R_HOME /usr/lib/R/

#Set the working directory for the application WORKDIR /app

#Copy the Python requirements file and install Python dependencies COPY requirements.txt /app/ RUN pip install --upgrade pip RUN pip install -r /app/requirements.txt

#Copy the rest of the application's code COPY . /app

#Set driver for HANA in odbcinst.ini RUN echo "[HDBODBC]\nDescription = HANA ODBC Treiber\nDriver = /usr/lib/libodbcHDB.dylib" > /etc/odbcinst.ini

#Reset the non-interactive frontend ENV DEBIAN_FRONTEND=

When I then start the container and a method is called in R that tries to establish a test connection via the odbc r package, I keep getting the following error message, even though the file is located at this path:

[01000] [unixODBC][Driver Manager]Can't open lib '/usr/lib/libodbcHDB.dylib' : file not found

i am trying to install a driver from UnixODBC in docker to be able to connect to HANA Express from R and expected to get a connection to hana express in r within docker

0

There are 0 best solutions below