title: Install / Configure SQL Server PDO driver for PHP docker image
body: <p>I have a simple docker file, as follows:</p>
  
  <pre><code>FROM php:7.2-apache
  COPY src/ /var/www/html/
  </code></pre>
  
  <p>Normally to install drivers for Mongo or MySQL connectivity I would do so by adding something like the below to the dockerfile:</p>
  
  <pre><code>docker-php-ext-install mongo
  </code></pre>
  
  <p>On this occasion I want to connect my php application to a SQL Server database, and I understand the best way to do this for php 7.x is by using the PDO driver, however I am unfamiliar with how to do configure this in the dockerfile.</p>
  
  <p>I've tried doing a pecl install, like adding:</p>
  
  <pre><code>RUN pecl install sqlsrv pdo_sqlsrv
  </code></pre>
  
  <p>However this fails with a combination of errors that do not seem to point me in the right direction.</p>
  
  <p>I'm just looking for a simple way to get this done in a dockerfile or by using docker run.</p>
  
  <p>For added info, here's the error I'm getting:</p>
  
  <pre><code>/tmp/pear/temp/sqlsrv/shared/xplat.h:30:17: fatal error: sql.h: No such file or directory
   #include &lt;sql.h&gt;
                   ^
  compilation terminated.
  Makefile:194: recipe for target 'conn.lo' failed
  make: *** [conn.lo] Error 1
  ERROR: `make' failed
  The command '/bin/sh -c pecl install sqlsrv pdo_sqlsrv     &amp;&amp; docker-php-ext-enable pdo_sqlsrv' returned a non-zero code: 1
  </code></pre>
  
  <p>Thanks all</p>