Conflict Between MSODBC and SQL Anywhere Drivers in Dockerized Debian

75 Views Asked by At

I am running a Django application in a Docker container based on Debian. My application needs to connect to both Microsoft SQL Server and SQL Anywhere databases, so I'm trying to use the Microsoft ODBC Driver (msodbcsql17) for SQL Server and the SQL Anywhere 17 driver. However, I'm encountering a frustrating issue: when the MSODBC driver is configured and working correctly, the SQL Anywhere driver stops working, and vice versa. I can't seem to have them both operational at the same time.

Environment:

  • Host OS: Windows
  • Docker Version: latest
  • Debian Image Version: python:3.10-bullseye
  • MSODBC Driver Version: 17
  • SQL Anywhere Driver Version: 17

Steps Taken:

  1. Installed Microsoft ODBC Driver 17 for SQL Server using official Debian packages or Microsoft's script.
  2. Installed SQL Anywhere driver using official packages and set up.
  3. Configured LD_LIBRARY_PATH to include paths to both drivers.
  4. Give full permisions to hole package

Symptoms:

  • When MSODBC is operational (confirmed by [describe successful connection to SQL Server), attempting to connect to SQL Anywhere results in .
  • Conversely, when SQL Anywhere is operational, attempting to connect to SQL Server via MSODBC results in "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.5.1' : file not found (0) (SQLDriverConnect)".

Questions:

  1. Has anyone faced a similar issue with these drivers in a Dockerized Debian environment?
  2. Are there known conflicts between these drivers that I should be aware of?
  3. Can you suggest any configurations or diagnostic steps to help isolate and resolve this conflict?

Any insights or suggestions would be greatly appreciated. Thank you in advance for your help!

# Use Debian Bullseye as the base image
FROM python:3.10-bullseye
# Environment variables
ENV PYTHONUNBUFFERED=1
# System dependencies
RUN apt-get update && apt-get install -y \
    libsasl2-dev \
    build-essential \
    libcairo2-dev \
    libjpeg-dev \
    zlib1g-dev \
    libfreetype6-dev \
    liblcms2-dev \
    libopenjp2-7-dev \
    libtiff5-dev \
    tk-dev \
    tcl-dev \
    tini \
    chromium \
    chromium-driver \
    curl \
    gnupg2 \
    unixodbc \
    unixodbc-dev
ARG PLATFORM
ENV PLATFORM=$PLATFORM
ENV PYTHONUNBUFFERED=1
ENV ISDOCKER=True
COPY . /code/
WORKDIR /code

ENV CHROME_BIN=/usr/bin/chromium-browser \
    CHROME_PATH=/usr/lib/chromium/
#
# Register the Microsoft Debian repository and import its GPG public key
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
    && curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list

# Install the Microsoft ODBC Driver 17 for SQL Server
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17

# Set environment variables for the driver
#
# install SQL anywhere 17
RUN apt-get update --fix-missing && apt-get install -y wget && \
    wget https://d5d4ifzqzkhwt.cloudfront.net/sqla17client/sqla17_client_linux_x86x64.tar.gz && \
    tar -xavf sqla17_client_linux_x86x64.tar.gz && \
    cd client17011 && \
    ./setup -nogui -I_accept_the_license_agreement -silent

## create a driver template
RUN echo "[SQL Anywhere 17]" >> /etc/odbcinst.ini
RUN echo "Description=SAP SQL Anywhere 17 ODBC Driver" >> /etc/odbcinst.ini
RUN echo "Driver=/opt/sqlanywhere17/lib64/libdbodbc17_r.so" >> /etc/odbcinst.ini
RUN echo "Setup=/opt/sqlanywhere17/lib64/libdbodbc17_r.so" >> /etc/odbcinst.ini
RUN echo "UsageCount=1" >> /etc/odbcinst.ini
#

# Application setup
RUN chmod +x "/code/start_api.sh" \
    && chmod +x "/code/start_worker.sh" \
    && chmod +x "/code/start_notificator.sh"

# SQL Anywhere paths
ENV SQLANY17="/opt/sqlanywhere17"
ENV SQLANYSAMP17="/opt/sqlanywhere17/samples"
ENV PATH="/lib/x86_64-linux-gnu/:$SQLANY17/bin64:$SQLANY17/bin32:${PATH:-}"
ENV LD_LIBRARY_PATH="$SQLANY17/lib64:${LD_LIBRARY_PATH:-}"
ENV LD_LIBRARY_PATH="/lib/x86_64-linux-gnu/:${LD_LIBRARY_PATH:-}"

RUN /usr/local/bin/python -m pip install --upgrade pip \
    && python -m pip install pipenv \
    && pipenv install --dev --deploy --system --ignore-pipfile

this works for sql anywhere

# Use Debian Bullseye as the base image
FROM python:3.10-bullseye
# Environment variables
ENV PYTHONUNBUFFERED=1
# System dependencies
RUN apt-get update && apt-get install -y \
    libsasl2-dev \
    build-essential \
    libcairo2-dev \
    libjpeg-dev \
    zlib1g-dev \
    libfreetype6-dev \
    liblcms2-dev \
    libopenjp2-7-dev \
    libtiff5-dev \
    tk-dev \
    tcl-dev \
    tini \
    chromium \
    chromium-driver \
    curl \
    gnupg2 \
    unixodbc \
    unixodbc-dev
ARG PLATFORM
ENV PLATFORM=$PLATFORM
ENV PYTHONUNBUFFERED=1
ENV ISDOCKER=True
COPY . /code/
WORKDIR /code

ENV CHROME_BIN=/usr/bin/chromium-browser \
    CHROME_PATH=/usr/lib/chromium/
#
# Register the Microsoft Debian repository and import its GPG public key
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
    && curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list

# Install the Microsoft ODBC Driver 17 for SQL Server
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17

# Set environment variables for the driver
#
# install SQL anywhere 17
RUN apt-get update --fix-missing && apt-get install -y wget && \
    wget https://d5d4ifzqzkhwt.cloudfront.net/sqla17client/sqla17_client_linux_x86x64.tar.gz && \
    tar -xavf sqla17_client_linux_x86x64.tar.gz && \
    cd client17011 && \
    ./setup -nogui -I_accept_the_license_agreement -silent

## create a driver template
RUN echo "[SQL Anywhere 17]" >> /etc/odbcinst.ini
RUN echo "Description=SAP SQL Anywhere 17 ODBC Driver" >> /etc/odbcinst.ini
RUN echo "Driver=/opt/sqlanywhere17/lib64/libdbodbc17_r.so" >> /etc/odbcinst.ini
RUN echo "Setup=/opt/sqlanywhere17/lib64/libdbodbc17_r.so" >> /etc/odbcinst.ini
RUN echo "UsageCount=1" >> /etc/odbcinst.ini
#

# Application setup
RUN chmod +x "/code/start_api.sh" \
    && chmod +x "/code/start_worker.sh" \
    && chmod +x "/code/start_notificator.sh"

# SQL Anywhere paths
ENV SQLANY17="/opt/sqlanywhere17"
ENV SQLANYSAMP17="/opt/sqlanywhere17/samples"
ENV PATH="/lib/x86_64-linux-gnu/:$SQLANY17/bin64:$SQLANY17/bin32:${PATH:-}"
ENV LD_LIBRARY_PATH="$SQLANY17/lib32:${LD_LIBRARY_PATH:-}"
ENV LD_LIBRARY_PATH="/lib/x86_64-linux-gnu/:${LD_LIBRARY_PATH:-}"

RUN /usr/local/bin/python -m pip install --upgrade pip \
    && python -m pip install pipenv \
    && pipenv install --dev --deploy --system --ignore-pipfile

this works for mssql

ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.5.1
        linux-vdso.so.1 (0x00007ffc3504d000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f00e1760000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f00e1756000)
        libodbcinst.so.2 => /opt/sqlanywhere17/lib64/libodbcinst.so.2 (0x00007f00e14ba000)
        libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f00e13e0000)
        libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f00e138d000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f00e11be000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f00e107a000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f00e1060000)```
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f00e103e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f00e0e6a000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f00e1b82000)
        libdbtasks17_r.so => /opt/sqlanywhere17/lib64/libdbtasks17_r.so (0x00007f00e0c20000)
        libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f00e0c04000)
        libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f00e0bd4000)
        libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f00e0bce000)
        libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f00e0bbf000)
        libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f00e0bb8000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f00e0b9e000)
0

There are 0 best solutions below