# PHP postgresql in docker compose

**URL:** <https://forums.docker.com/t/php-postgresql-in-docker-compose/104159>\
**Category:** General\
**Tags:** docker\
**Created:** [February 8, 2021, 5:40pm UTC](https://forums.docker.com/t/php-postgresql-in-docker-compose/104159 "2021-02-08T17:40:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raymhi](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@raymhi](https://forums.docker.com/u/raymhi)\
**Post date:** [February 8, 2021, 5:40pm UTC](https://forums.docker.com/t/php-postgresql-in-docker-compose/104159/1 "2021-02-08T17:40:55Z")

</div>

Hello,

I take the liberty of writing to you because I am blocked on a point that you will undoubtedly find basic.

I am unable to activate the php pgsql extension.

I am on an Unbuntu server and here is my docker compose.

> Blockquote  
> version: ‘2’  
> services:  
> web:  
> image: lavoweb/php-7.4  
> ports:  
> - “80:80”  
> volumes:  
> - /var/www:/var/www/html  
> - /var/docker/php.ini-development:/usr/local/etc/php/php.ini-development  
> - /var/docker/php.ini-production:/usr/local/etc/php/php.ini-production  
> links:  
> - db:db  
> db:  
> image: postgres  
> restart: always  
> volumes:  
> - /mnt/postgresql:/var/lib/postgresql/data  
> environment:  
> POSTGRES\_PASSWORD: Alcapone!257  
> PGDATA: /var/lib/postgresql/data/pgdata  
> adminer:  
> image: adminer  
> restart: always  
> ports:  
> - 8080:8080

I did add “extension = pgsql.so” in the php.ini, but the “extension\_loaded (‘pgsql’)” function tells me that it is not activated.

I don’t know how to install it with my php image.

cordially.

---

<div class="post-metadata">

**Author:** ![raymhi](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@raymhi](https://forums.docker.com/u/raymhi)\
**Post date:** [February 9, 2021, 10:36am UTC](https://forums.docker.com/t/php-postgresql-in-docker-compose/104159/2 "2021-02-09T10:36:26Z")

</div>

Hi,

resolve with this :

> <https://github.com/docker-library/php/issues/221>
>
> I was trying to install pdo\_psql on fpm-alpine flavour like:
> docker-php-ext-install pdo pdo\_pgsql
> I was getting first the following error:
> configure: error: Cannot find...

I add this code in image build of php :

```auto
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-install pgsql pdo_pgsql

```

---

<div class="post-metadata">

**Author:** ![ogurchik7](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ogurchik7/32/32475_2.png) [@ogurchik7](https://forums.docker.com/u/ogurchik7)\
**Post date:** [November 1, 2022, 7:25pm UTC](https://forums.docker.com/t/php-postgresql-in-docker-compose/104159/4 "2022-11-01T19:25:01Z")

</div>

Can you tell more? Where did you add this `RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ && docker-php-ext-install pgsql pdo_pgsql`  
I can’t understand how add command RUN in docker-compose.
