Richard Bernstein
Richard Bernstein

Reputation: 371

Why can't I run pdo_pgsql in my container?

I am trying to use AWS RDS postgresql from my php app. I have modified the Dockerfile to contain RUN apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo pdo_pgsql But it doesn't seem to run. I think this because when I (finally) ran phpinfo() from the container, I don't see it loaded. I am assuming that when I run docker-compose up, the Dockerfile (that builds php-fpm) is run "automatically". Is that true? Here is the Dockerfile that doesn't seem to run:

FROM bitnami/php-fpm:7.2 as builder
RUN install_packages git autoconf build-essential
WORKDIR /app
RUN wget https://github.com/xdebug/xdebug/archive/2.6.0.tar.gz && \
    tar xzf 2.6.0.tar.gz && \
    cd xdebug-2.6.0 && \
    phpize && \
    ./configure --enable-xdebug && \
    make && make install
RUN apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo pdo_pgsql

FROM bitnami/php-fpm:7.2
COPY --from=builder /opt/bitnami/php/lib/php/extensions/xdebug.so /opt/bitnami/php/lib/php/extensions/
RUN echo 'zend_extension="/opt/bitnami/php/lib/php/extensions/xdebug.so"' >> /opt/bitnami/php/etc/php.ini

RUN echo "xdebug.remote_port=9000" >> /opt/bitnami/php/etc/php.ini \
    && echo "xdebug.remote_enable=1" >> /opt/bitnami/php/etc/php.ini \
    && echo "xdebug.remote_connect_back=0" >> /opt/bitnami/php/etc/php.ini \
    && echo "xdebug.remote_host=192.168.122.1" >> /opt/bitnami/php/etc/php.ini \
    && echo "xdebug.idekey=docker" >> /opt/bitnami/php/etc/php.ini \
    && echo "xdebug.remote_autostart=1" >> /opt/bitnami/php/etc/php.ini \
    && echo "xdebug.remote_log=/tmp/xdebug.log" >> /opt/bitnami/php/etc/php.ini \
    && echo "extension=pgp_pdo_pgsql.so" >> /opt/bitnami/php/etc/php.ini \
    && echo "extension=pgp_pgsql.so" >> /opt/bitnami/php/etc/php.ini

And here is the docker-compose

version: '3'

services:

  apache:
    image: bitnami/apache:latest
    restart: unless-stopped
    ports:
      - 80:8080
    volumes:
      - ./apache/app.conf:/vhosts/app.conf:ro
      - ./app:/app
    networks:
      - net

  mysql:
    container_name: "mysql"
    restart: unless-stopped
    image: mysql:5.6
    environment:
      - MYSQL_DATABASE
      - MYSQL_PASSWORD
      - MYSQL_ROOT_PASSWORD
      - MYSQL_USER
    volumes:
      - data:/var/lib/mysql
      - ./mysql/mysql.sql:/docker-entrypoint-initdb.d/mysql.sql
    ports:
      - "3306:3306"
    networks:
      - net

  phpmyadmin:
    container_name: phpmyadmin
    restart: unless-stopped
    image: phpmyadmin/phpmyadmin
    environment:
      - PMA_HOST=mysql
      - PMA_PORT=3306
    ports:
      - "8081:80"
    networks:
      - net

  php-fpm:
    build: ./php
    restart: unless-stopped
    image: bitnami/php-fpm
    volumes:
      - ./app:/app
    environment:
      - XDEBUG_CONFIG="remote_host=192.168.122.1"
    networks:
      - net

  jasperreports:
    image: 'bitnami/jasperreports:7'
    restart: unless-stopped
    environment:
      - MARIADB_HOST=mysql
      - MARIADB_PORT_NUMBER=3306
      - JASPERREPORTS_USERNAME=admin
      - JASPERREPORTS_PASSWORD=bitnami
      - JASPERREPORTS_DATABASE_USER=admin
      - JASPERREPORTS_DATABASE_PASSWORD=xxx
      - JASPERREPORTS_DATABASE_NAME=jasper
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - '8080:8080'
    volumes:
      - jasperreports_data:/bitnami
    depends_on:
      - mysql
    networks:
      - net


volumes:
  data:
    driver: local
  jasperreports_data:
    driver: local

If this Dockerfile is not being run automatically, how do I get it to create a new php-fpm container?

Upvotes: 2

Views: 1849

Answers (1)

nischay goyal
nischay goyal

Reputation: 3480

If you change Dockerfile and you want to update the image with docker-compose up, then you need to pass the flag --build with docker-compose up.

--build Build images before starting containers.

docker-compose up --build

Ref:- https://docs.docker.com/compose/reference/up/

Upvotes: 3

Related Questions