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?