0

我正在尝试将遗留项目移动到使用 msodbcsql 和 pdo_odbc 驱动程序连接到 SQL Server 数据库的 docker。

我的码头文件:

#install freetds
RUN apt-get update && \
    apt-get install -y gnupg2 && \
    apt-get install -y apt-transport-https && \
    curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
    curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
    apt-get update

RUN ACCEPT_EULA=Y \
    apt-get install -y unixodbc unixodbc-dev libgss3 odbcinst msodbcsql locales freetds-dev && \
    echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
    locale-gen && \
    rm -rf /var/lib/apt/lists/*

RUN apt-get update && \
    apt-get install -y git freetds-dev zlib1g-dev && \
    rm -rf /var/lib/apt/lists/*

#pdo_odbc drivers
RUN apt-get install -y \
    unixODBC-dev \
    && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \
    && docker-php-ext-install pdo_odbc \
    && docker-php-ext-enable pdo_odbc

#Config files from current debian server
COPY ./freetds.conf /etc/freetds/freetds.conf
COPY ./odbc.ini /etc/odbc.ini
COPY ./odbcinst.ini /etc/odbcinst.ini

在安装过程中,我没有收到任何错误,并且在尝试连接到 SQL Server 时,我收到以下错误:

"error":"SQLSTATE[01000] SQLConnect: 0 [unixODBC][Driver Manager]Can't open lib '\/opt\/microsoft\/msodbcsql\/lib64\/libmsodbcsql-11.0.so.2270.0' : file not found"
4

1 回答 1

0

尝试使用以下代码在您的 docker 上安装 pdo_sqlsrv 和 msodbcsql:

# Install selected extensions and other stuff
RUN apt-get update \
    && apt-get -y --no-install-recommends install wget php-memcached php7.2-mysql php-redis php7.2-bz2 php7.2-gd php-imagick php7.2-odbc php7.2-xmlrpc php-yaml \
    && apt-get -y install unixodbc-dev; apt-get -y install php-pear; apt-get install -y php7.2-dev;\
    pecl install sqlsrv pdo_sqlsrv;

# Install ODBC
RUN wget https://packages.microsoft.com/ubuntu/17.04/prod/pool/main/m/msodbcsql/msodbcsql_13.1.9.1-1_amd64.deb;
RUN apt-get -y install unixodbc libcurl3;
RUN ACCEPT_EULA=Y \
    dpkg -i msodbcsql_13.1.9.1-1_amd64.deb;
RUN apt-get install -y locales \
    && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen\
    && locale-gen;
于 2019-02-16T09:19:12.757 回答