0

Good Morning,

I am having the following issue with my Docker container and pyodbc / unixodbc-dev.

When running my Python API connecting to my Docker container I get the following error message--

(pyodbc.Error) ('01000', "[01000] [unixODBC][Driver
Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)"

Connecting to the same API using my local debug instance everything is working fine -- I can submit a string for searching in the backend database and I get results returned and sent back to the Postman UI.

I see that unixodbc-dev dev 2.3.6-0.1 amd64 installed in the Docker image and I noticed that unixODBC is at 2.3.11 - don't know if there might be any issue with that but that being said our Moonshot instances can't connect to http://deb.debian.org and to get our security group to open it up is next to impossible.

All this being said I'm wondering if I have something configured wrong in my Docker container that is causing my issues. I'm new to the Docker container world so this is definitely a learn as I go.

TIA, Bill Youngman

B. Youngman
  • 123
  • 1
  • 12
  • Additional information -- the connection string that is being used to connect is mssql+pyodbc://admin:validusdev@validus-rds-xe1-dev-name-matching.cf2xhi0isp7k.us-east-1.rds.amazonaws.com:1433/NameMatching?driver=ODBC+Driver+17+for+SQL+Server – B. Youngman Jun 09 '22 at 18:35

1 Answers1

0

I was able to get this figured out - thanks to m.b. for the solution I was looking for.

I was able to take the Debian suggestion from this Install ODBC driver in Alpine Linux Docker Container and modify it for my needs.

This is the code that I used to meet my requirements of downloading unixOdbc as well as downloading and installing the MS Sql ODBC driver.

FROM python:3.8.3

ARG ENV DEBIAN_FRONTEND noninteractive

# install Microsoft SQL Server requirements.
ENV ACCEPT_EULA=Y
RUN apt-get update -y && apt-get update \
  && apt-get install -y --no-install-recommends curl gcc g++ gnupg unixodbc-dev

# Add SQL Server ODBC Driver 17 for Ubuntu 18.04
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 \
  && apt-get update \
  && apt-get install -y --no-install-recommends --allow-unauthenticated msodbcsql17 mssql-tools \
  && echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile \
  && echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

# clean the install.
RUN apt-get -y clean

Once this was accomplished and I built and deployed my container everything worked perfectly.

-Bill

B. Youngman
  • 123
  • 1
  • 12