[Microsoft][ODBC驱动程序17 for SQL Server]SSPI提供程序:没有可用的Kerberos凭据

2024-05-19 10:54:45 发布

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

我开发了Django应用程序,并从Django应用程序连接远程sql server。 若我在anaconda环境中运行它,它运行良好,但若我构建docker容器,它会给我错误

sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0) (851968) (SQLDriverConnect)') (Background on this error at: http://sqlalche.me/e/dbapi)

这是Dockerfile

FROM python:3

ENV PYTHONUNBUFFERED 1

WORKDIR /app

ADD . /app

COPY ./requirements.txt /app/requirements.txt



RUN apt-get update \
  && apt-get -y install gcc gnupg2 \
  && 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

RUN apt-get update \
  && ACCEPT_EULA=Y apt-get -y install msodbcsql17 \
  && ACCEPT_EULA=Y apt-get -y install mssql-tools


RUN apt-get -y install unixodbc-dev \
  && apt-get -y install python-pip \
  && pip install pyodbc


RUN pip install --upgrade pip
RUN pip install Django
RUN pip install python-dotenv
RUN pip install --user django-crispy-forms
RUN pip install pandas
RUN pip install SQLAlchemy
RUN pip install django-pyodbc-azure-2019

COPY . /app

这是接线

engine = create_engine('mssql+pyodbc://' + 'SQLserver' + '/' + 'database' + "?" + 'driver=ODBC Driver 17 for SQL Server')


Tags: installpipdjangorunapp应用程序getdriver

热门问题