Search code examples
dockerodbchanaunixodbc

How to install HDBODBC Drivers in a Linux Dockerfile?


I am trying to connect to a SAP HANA database from a Linux Dockerfile. Currently having trouble with installing the HDBODBC Driver in the Dockerfile or finding resources for it.

  1. How can I install HDBODBC Driver in a Dockerfile?
  2. Do I need an odbc.ini file or is using a connection string sufficient?

Note: I am familiar with connecting to SAP HANA without docker and on Windows using a connection string

Dockerfile currently:

FROM --platform=linux/amd64 node:16.13.0

WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install

RUN apt-get update && apt-get install -y unixodbc unixodbc-dev
RUN apt-get install odbcinst

COPY . .
EXPOSE 8080
CMD ["node", "src/index.js"]

When I run my code with just the connection string I am seeing:

[Error: [odbc] Error connecting to the database] {
   odbcErrors: [
     {
       state: '01000',
       code: 0,
       message: "[unixODBC][Driver Manager]Can't open lib 'HDBODBC' : file not found"
     }
   ]
 }

Which makes me think I don't have the driver installed


Solution

  • You need the HANA Client. Try here: https://tools.hana.ondemand.com/#hanatools