pglayers: PostgreSQL extensions as stackable Docker layers

PostgreSQL · 8 Jul 2026 · 2 min read

#postgresql

The pglayers project introduces a novel approach to including PostgreSQL extensions in Docker deployments. Instead of building extensions into a custom image or installing them via package managers at runtime, pglayers publishes each extension as a minimal Docker image built from FROM scratch. These images contain only the essential files: shared libraries, control files, SQL scripts, and correct filesystem paths.

  • Ready-to-use layers: Extensions like pgvector, PostGIS, pgRouting, TimescaleDB, pg_duckdb, h3-pg, and pg_cron are available as separate images. You compose them onto the official postgres image using COPY --from=: FROM postgres:17 then COPY --from=ghcr.io/pglayers/pgx-pgvector:17 / /, etc.
  • No build steps: No apt-get, no make, no compilation. The final image stays lean — just the official Postgres plus the extension binaries.
  • Preconfigured full image: ghcr.io/pglayers/pglayers-full:17 includes all 53 extensions with shared_preload_libraries already set. There's also an Azure profile (28 extensions) matching Azure Database for PostgreSQL Flexible Server, ideal for local dev/test.
  • Extensions covered: 53 extensions across categories: AI/ML (pgvector), Geospatial (PostGIS, pgRouting, h3-pg), Time-series (TimescaleDB), Analytics (pg_duckdb), Observability, and more.

For developers, this means drastically simpler Dockerfile maintenance and faster iteration. No more custom build stages or dependency hell. To use an extension, just CREATE EXTENSION as usual after layering. This approach also enables sharing extension sets (e.g., an Azure-compatible profile) and ensures consistency between development and production environments.

Source: https://www.postgresql.org/about/news/pglayers-postgresql-extensions-as-stackable-docker-layers-3344/

Related

auto-curated · source linked above ← all news