E
E
EVOSandru62018-09-26 08:59:04
PHP
EVOSandru6, 2018-09-26 08:59:04

How to install php-pgsql client on php:7.1-cli container?

Good afternoon,
The postgres container itself is definitely working, connected, manipulated data through the Database manager . The problem is to make it friends with php{''|7.1}
Fragment docker-compose.yml

php-cli:
    build: ${CONTAINERS_PATH}/php-cli
    volumes:
      - ${APP_PATH_HOST}:/var/www
    environment:
      - DB_CONNECTION=pgsql
      - DB_PORT=5432
      - DB_HOST=pgsql
    tty: true
pgsql:
    image: postgres:latest
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DATABASE=${DB_NAME}
    ports:
      - 54321:5432
    volumes:
      - ./storage/docker/postgres/:/docker-entrypoint-initdb.d/

There is such a Dockerfile :
FROM php:7.1-cli
RUN apt-get update && apt-get install -y libmcrypt-dev php-pgsql; ## или php7.1-pgsql, тот же результат
RUN docker-php-ext-install mcrypt pcntl pdo pdo_pgsql;
WORKDIR /var/www

With
docker-compose-up:
E: Package 'php-pgsql' has no installation candidate
ERROR: Service 'php-cli' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libmcrypt-dev php -pgsql; ## php7.1-pgsql' returned a non-zero code: 100

If I change Dockerfile to: (remove php-pgsql )
FROM php:7.1-cli
RUN apt-get update && apt-get install -y libmcrypt-dev; 
RUN docker-php-ext-install mcrypt pcntl pdo pdo_pgsql;
WORKDIR /var/www

I catch:
checking for pg_config... not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
ERROR: Service 'php-cli' failed to build: The command '/bin/sh -c docker-php-ext-install mcrypt pcntl pdo pdo_mysql pdo_pgsql;' returned a non-zero code: 1

Please tell me - if anyone came across.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Telepnev, 2018-09-26
@EVOSandru6

I solved this problem like this

RUN set -ex \
    && echo "deb http://ftp.de.debian.org/debian stretch main" >> /etc/apt/sources.list \
    && apt-get update \
    && apt-get install -y php-pgsql

Not sure if it's right, but it works

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question