Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Setting Postgres extensions via POSTGRESQL_EXTENSIONS env

Aperta
#669 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
docker, postgresql
Ambito
databases, devops

Direzione di ricerca

Start with the PostgreSQL 15 logic in root/usr/share/container-scripts/postgresql/common.sh around lines 491-498, then inspect the extension test in test/run_test around lines 1079-1088. Reproduce the issue using the provided podman command and verify whether POSTGRESQL_EXTENSIONS is processed during initialization. Done means the reported pg_trgm setup behavior is explained and the test or initialization behavior is corrected.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hey Gang!

I'm attempting to start Postgres-15 with an extension: POSTGRESQL_EXTENSIONS="pg_trgm" but it does not seem to work as expected

The shell script here seems to be where the action happens:
https://github.com/sclorg/postgresql-container/blob/4d36fddfb7afb5bbb3e1eaa78c3c132f5ee807cb/15/root/usr/share/container-scripts/postgresql/common.sh#L491-L498

For context, I'm setting up a Quay instance with Postgres and that requires the pg_trgm extension.

Steps to reproduce:

##
## Setup storage and fix permissions
##
sudo mkdir -pv /mnt/quay/postgres-data
sudo setfacl -m u:26:-wx /mnt/quay/postgres-data

##
## Run the container
##
sudo podman pod create \
  --name quay-pod \
  -p 80:8080 \
  -p 443:8443

sudo podman run \
  --name quay_postgres \
  --pod quay-pod \
  --rm -d \
  -e POSTGRESQL_USER=quayuser \
  -e POSTGRESQL_PASSWORD=quaypass \
  -e POSTGRESQL_DATABASE=quay \
  -e POSTGRESQL_ADMIN_PASSWORD=adminpass \
  -e POSTGRESQL_EXTENSIONS="pg_trgm " \
  -v /mnt/quay/postgres-data:/var/lib/pgsql/data:Z \
  quay.io/fedora/postgresql-15

##
## The verification step will show if the "pg_trgm" extension was installed.
##
sudo podman exec -it quay_postgres  psql -U quayuser -d quay -c "\dx pg_trgm"

     List of installed extensions
 Name | Version | Schema | Description 
------+---------+--------+-------------
(0 rows)

The pg_trgm extension does in fact work if setup after the container is running.

sudo podman exec -it quay_postgres psql -U quayuser -d quay -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
sudo podman exec -it quay_postgres  psql -U quayuser -d quay -c "\dx pg_trgm"

CREATE EXTENSION
                                  List of installed extensions
  Name   | Version | Schema |                            Description
---------+---------+--------+-------------------------------------------------------------------
 pg_trgm | 1.6     | public | text similarity measurement and index searching based on trigrams
(1 row)

So it appears the feature to run extensions from the environment variable is not working, at least not in this case.
I see there are tests for the feature:
https://github.com/sclorg/postgresql-container/blob/4d36fddfb7afb5bbb3e1eaa78c3c132f5ee807cb/test/run_test#L1079-L1088
But I'm not sure how well that test works, and I've not tried running the test myself (not yet).

Can somebody chime in and say if the issue is legit?
Thanks in advance!

Lingua principale
PLpgSQL
Stelle
178
Fork
220
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sclorg/postgresql-container

Tutte le issue di sclorg/postgresql-container

Issue simili

Altre issue su Databases

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.