PHP 7.1 FPM missing PostgreSQL even though it's installed and loaded

Hey guys, I have installed PDO PGSQL as follows in php 7.1 FPM image but PHP is still complaining that it can not find the driver.

FROM php:7.1-fpm
RUN sed -i 's/127.0.0.1:9000/0.0.0.0:9000/g' /usr/local/etc/php-fpm.d/www.conf \
   && apt-get update && apt-get install -y libpq-dev \
   && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
   && docker-php-ext-install pdo pgsql pdo_pgsql \
   && docker-php-ext-enable pdo pgsql pdo_pgsql

libpq version is 9.4, postgres server 9.4. on Alpine

I have tried all combinations and all SO questions and tickets over on Github, and nothing really helps.

I am having a similar problem. No errors reported during build, but when I check the container the module is not listed (php -m) and there’s not extension config file in php.d. I am using a different repo, polinux/httpd:centos. What’s really odd is that I can install it manually after starting the container, but then I can’t restart apache without restarting the container.
I’ve tried moving yum install php71-php-pgsql to the end of the Dockerfile as a separate RUN command, but it reports it has already been installed, yet when I ssh into the container its not listed.
Did you ever figure this out?
Thanks.

Yes, I have that figured out. It was the following

apt-get install --no-install-recommends -y libpq-dev 
 docker-php-ext-install pdo pgsql pdo_pgsql 

Other commands were not needed.