Pre‑built PostgreSQL extensions as composable Docker image layers
Project: https://github.com/pglayers/pglayers
pglayers publishes 53 PostgreSQL extensions as minimal Docker images (FROM scratch).
Each image contains only:
You compose them onto the official postgres Docker image using COPY --from:
dockerfile
FROM postgres:17
COPY --from=ghcr.io/pglayers/pgx-pgvector:17 / /
COPY --from=ghcr.io/pglayers/pgx-postgis:17 / /
COPY --from=ghcr.io/pglayers/pgx-pg_cron:17 / /
No compilation.
No apt-get.
No build tools in the final image.
Just CREATE EXTENSION as usual.
For a fully preconfigured setup:
bash
docker run -d -e POSTGRES_PASSWORD=s ghcr.io/pglayers/pglayers-full:17
Includes:
shared_preload_libraries already setAlso available:
53 extensions across major categories:
Full list: https://github.com/pglayers/pglayers#available-extensions
All images support linux/amd64 and linux/arm64.
PostgreSQL 18 introduces extension_control_path and dynamic_library_path.
pglayers uses these to place each extension in its own namespace:
/extensions/<name>/
Benefits:
Example:
dockerfile
COPY --from=ghcr.io/pglayers/pgx-pgvector:18 / /extensions/pgvector/
COPY --from=ghcr.io/pglayers/pgx-pg_cron:18 / /extensions/pg_cron/
PostgreSQL locates them via:
extension_control_path = '/extensions/pgvector/share:/extensions/pg_cron/share:$system'
dynamic_library_path = '/extensions/pgvector/lib:/extensions/pg_cron/lib:$libdir'
Fully compatible with CloudNativePG ≥ 1.27, which auto‑manages these GUCs.
The test suite validates:
ldd) CREATE EXTENSION succeeds for every extension Only permissive open-source licenses:
PostGIS and pgRouting (GPL‑2.0) included under the standard mere aggregation interpretation used in the PostgreSQL ecosystem.
No BSL, SSPL, or proprietary-dependency extensions.
Contributions welcome!
Adding a new extension requires:
Dockerfile extension.conf test.sqlSee CONTRIBUTING.md for details.
Feedback, bug reports, and extension requests via GitHub Issues.
This project stands on the shoulders of the PostgreSQL community:
pglayers is a thin layer of automation on top of their work. Without the quality and consistency of the upstream ecosystem, this project would not exist.
Thanks!
Ismael Mejia