PDO Driver for Postgres Docker, does not install

Asked

Viewed 96 times

1

I set up a PHP + Apache environment using Docker (so far everything OK), however, I noticed that PHP does not come with the PDO_PGSQL driver installed in the image.. I searched, found some solutions but could not install/run the driver. I even tried to copy a php.ini that I already had, but it didn’t work either.

Follow below my files:

php. Dockerfile

# Imagem de origem
FROM php:7.1-fpm

# Mantenedor
LABEL maintainer="[email protected]"

# tentei copiar o ini, tambem nao funcionou.
# ADD php.ini /usr/local/etc/php

# ====== DRIVERS PHP ========
#
# -> PDO MYSQL
# RUN docker-php-ext-install mysqli pdo_mysql
#
# -> PDO POSTGRESQL
# RUN apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo_pgsql # Nao funciona
#
#
# tentei assim, porém, tambem nao funciona.
RUN 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 \
&& apt-get clean

apache. Dockerfile

# Imagem de origem
FROM php:apache

# Mantenedor
LABEL maintainer="[email protected]"

# Setando o modo de reescrita de URL no apache.
RUN a2enmod rewrite

Docker-Compose.yml

version: "3" 
services:
# Servidor Apache
apache:
    build:
      dockerfile: apache.Dockerfile
      context: ./Docker/apache
    volumes:
      - "./app/src:/var/www/html"
    ports:
      - "80:80"
    depends_on:
      - php
    container_name: apache

  # Codigos da aplicação
  php:
    build:
      dockerfile: teste.Dockerfile
      context: ./Docker/php
    volumes:
      - "./app/src:/var/www/html"
    ports:
      - "9000:9000"
    container_name: php

Even following some tutorials, reading the doc I could not solve the problem. Containers mount and no error is returned, however when running phpinfo() I see that the only existing PDO driver is sqlite.

That’s it, thanks to anyone who can help!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.