在docker imag中安装pyodbc

2024-04-19 03:59:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用https://hub.docker.com/r/tiangolo/meinheld-gunicorn-flask/来托管flask api。在

为了部署,我使用了一个docker映像,该映像位于azure web app services for container上。我正在尝试将我的flask应用程序连接到Azure SQL server。但是我在安装正确的odbc驱动程序和pyodbc时遇到了问题。在

我的docker文件:

FROM ubuntu:16.04
# apt-get and system utilities
RUN apt-get update && apt-get install -y \
    curl apt-utils apt-transport-https debconf-utils gcc build-essential g++-5\
    && rm -rf /var/lib/apt/lists/*
# adding custom MS repository
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

# install SQL Server drivers
RUN apt-get update && ACCEPT_EULA=Y apt-get -y install msodbcsql17
RUN apt-get -y install unixodbc unixodbc-dev

# install necessary locales
RUN apt-get update && apt-get install -y locales \
    && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
    && locale-gen


FROM tiangolo/meinheld-gunicorn:python3.7
ENV LISTEN_PORT=80
EXPOSE 80

COPY /app /app

# Uncomment to install additional requirements from a requirements.txt file
COPY requirements.txt /


RUN pip install --no-cache-dir -U pip
RUN pip install --no-cache-dir -r /requirements.txt

获取错误:

^{pr2}$

我想是因为unixodbc没有正确安装?在


Tags: installdockerrunhttpscomappflaskget