我正在尝试将遗留项目移动到使用 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"