1

I have a Python Flask application running in a Docker container that connects to MS SQL Server (a corporate database) via SQLAlchemy. However, I am getting package conflicts when I try to build the container. Here is my Dockerfile:

FROM python:3.7-stretch

# Get the ODBC driver for Microsoft SQL Server
RUN apt-get update \
&& apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/9/prod.list  > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get -y install --no-install-recommends msodbcsql17 \
    unixodbc \
    unixodbc-bin \
    unixodbc-dev \
&& apt-get clean

# Setup the project
RUN mkdir -p /app
WORKDIR /app

COPY . .

RUN python setup.py install

CMD [ '/bin/bash' ]

When I build this, I get:

 unixodbc : Conflicts: unixodbc-bin (< 2.3.7) but 2.3.0-4+b1 is to be installed

This was working, as far as I can tell from my build logs, on 25-FEB-2019, but it's possible it was using cached images.

I have tried to use specific versions for the libraries to avoid the issue:

&& ACCEPT_EULA=Y apt-get -y install --no-install-recommends msodbcsql17=17.2.0.1-1 \
    unixodbc=2.3.4-1 \
    unixodbc-bin=2.3.0-4+b1 \
    unixodbc-dev=2.3.4-1 \
    libodbc1=2.3.4-1 \
    odbcinst1debian2=2.3.4-1 \
    odbcinst=2.3.4-1 \
&& apt-get clean

And that builds the container ok with --no-cache, but when the application tries to connect to the database it just hangs forever. I've also used msodbcsql17=17.1.0.1-1 and get the same result.

Here is my app's setup.py:

from setuptools import setup, find_packages

setup(name='catfnolbackend',
      version='0.1.0',
      packages=find_packages(),
      package_dir={'catfnolbackend': 'catfnolbackend'},
      include_package_data=True,
      platforms='any',
      install_requires=['Flask==1.0.2',
                        'flask-cors==3.0.6',
                        'SQLAlchemy==1.2.13',
                        'geoalchemy2==0.5.0',
                        'pyodbc==4.0.24',
                        'flask-dance==1.3.0',
                        'flask-login==0.4.1',
                        'blinker==1.4'
                        ],
      setup_requires=['pytest-runner'],
      tests_require=['pytest'],
      )

If I remove the extra libs and just use msodbcsql17 then pyodbc 4.0.24 doesn't build, either.

Are there better versions of unixodbc I should specify? Are there change-logs I've missed that would give background on why the dependency suddenly broke?

Merkidemis
  • 2,801
  • 2
  • 20
  • 26
  • I just did a successful install of msodbcsql17 17.3.1.1-1 and pyodbc 4.0.26 on a clean install of Debian 9 "Stretch" (Xfce). In late February 2019 Microsoft did start including unixodbc 2.3.7 in their repo because of a bug in earlier versions that messed up ODBC logging (and perhaps other issues), and Microsoft has had a few difficulties with Stretch deployment in the past, so maybe this is something that has worked itself out between msodbcsql17 versions 17.2 and 17.3. – Gord Thompson Mar 08 '19 at 17:18
  • Thanks! I'm still having issues with things like unixodbc-bin not liking 2.3.7, but I've worked around the issue. The earlier section where I specified the versions for everything I was able to get working after restarting the database, so clearly an issue there instead of the libraries being weird. – Merkidemis Mar 11 '19 at 14:47

1 Answers1

1

After restarting the database (the real reason for my connection attempts hanging), specifying the versions of each library now works:

&& ACCEPT_EULA=Y apt-get -y install --no-install-recommends msodbcsql17=17.2.0.1-1 \
    unixodbc=2.3.4-1 \
    unixodbc-bin=2.3.0-4+b1 \
    unixodbc-dev=2.3.4-1 \
    libodbc1=2.3.4-1 \
    odbcinst1debian2=2.3.4-1 \
    odbcinst=2.3.4-1 \
&& apt-get clean
Merkidemis
  • 2,801
  • 2
  • 20
  • 26