How to install/enable pdo-odbc driver on a php docker container?

前端 未结 2 1534
無奈伤痛
無奈伤痛 2021-01-16 07:11

I am currently having trouble writing a Dockerfile for my php application. My Dockerfile works but lacks the pdo-odbc driver I need to connect to an MS SQL Server database.

相关标签:
2条回答
  • 2021-01-16 07:22

    According to https://github.com/docker-library/php/issues/103 you can try this:

    FROM php
    RUN apt-get update && apt-get install -y unixODBC-dev && rm -rf /var/lib/apt/lists/*
    RUN set -x \
    && cd /usr/src/php/ext/odbc \
    && phpize \
    && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \
    && ./configure --with-unixODBC=shared,/usr \
    && docker-php-ext-install odbc
    
    0 讨论(0)
  • 2021-01-16 07:45

    This worked for me:

    RUN apt-get install unixodbc unixodbc-dev -y \
     && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \
     && docker-php-ext-install pdo_odbc
    
    0 讨论(0)
提交回复
热议问题