PostgreSQL 和 Docker 图像具有您实际需要的扩展 - 已预构建、可组合、无需编译
The official PostgreSQL Docker images ship without extensions. Every time you need pgvector, PostGIS, or pg_cron, you're stuck manually installing dependencies, compiling from source, or settling for third-party images that bundle a fixed set of extensions.
pglayers fixes this. It's both a ready-to-use PostgreSQL distribution
with extensions pre-installed and a tool to build your own custom
image with exactly the extensions you need -- all on top of the
official postgres Docker images. You don't need to figure out how to
build PostgreSQL extensions, install dependencies, or set up compilers.
Each extension is published as a minimal Docker image layer containing
only its binaries. You stack them on top of the official postgres
image using COPY --from -- one line per extension, no compilation.
Pre-built combined images with shared_preload_libraries already
configured:
# All 80+ extensions
docker run -d -e POSTGRES_PASSWORD=secret ghcr.io/pglayers/pglayers-full:17
# Azure Database for PostgreSQL compatible (30+ extensions)
docker run -d -e POSTGRES_PASSWORD=secret ghcr.io/pglayers/pglayers-azure:17Available profiles: full, azure. Each is published for PG 17, 18,
and 19. See Profiles for details and how to create custom
ones.
The azure profile includes DocumentDB, providing MongoDB wire protocol
compatibility on port 10260 -- the same engine behind Azure DocumentDB.
Note: Vendor profiles (e.g.,
azure) are a best-effort approximation for local development. They are not a replacement for the actual managed service -- extension versions, configuration defaults, and platform-specific behavior may differ. Use them to develop and test locally, not to replicate production exactly.
Each extension is published as its own image layer. You stack them onto
the official postgres image with COPY --from -- each line adds one
extension to the final image:
FROM postgres:17
COPY --from=ghcr.io/pglayers/pgx-pgvector:17 / /
COPY --from=ghcr.io/pglayers/pgx-pg_cron:17 / /
COPY --from=ghcr.io/pglayers/pgx-postgis:17 / /Build and run:
docker build -t my-postgres .
docker run -d -e POSTGRES_PASSWORD=secret my-postgresNo compilation happens -- Docker pulls the pre-built extension layers from the registry and overlays them onto the official image. The result is a single image with exactly the extensions you chose, composed layer by layer.
Starting with PostgreSQL 18, pglayers uses an isolated extension
layout that leverages PostgreSQL's extension_control_path GUC. Each
extension lives in its own /extensions// namespace, eliminating
file collision risk entirely:
…No linker configuration (ld.so.conf.d/ldconfig/LD_LIBRARY_PATH) is
needed: each isolated layer is self-contained. Every ELF object it ships
carries an $ORIGIN RUNPATH pointing at its own
/extensions//lib, and any bundled runtime library it needs (e.g.
libcurl -> libssh2) has a per-extension-mangled soname
(pglx__). This keeps each layer's dependencies private, so
two extensions that bundle the same library (for example postgis and
pg_duckdb, both of which pull in libssh2 via libcurl) can never bind
to each other's copy in the shared postgres process. Configuring a global
linker path instead would collapse every soname to a single winner and
reintroduce exactly that cross-layer collision.
The $system and $libdir suffixes ensure built-in contrib extensions
(hstore, pg_stat_statements, etc.) remain discoverable.
Note: The pre-built profile images (
pglayers-full:18,pglayers-azure:18) handle all GUC and linker configuration automatically. The manual setup above is only needed when composing your own image with Option 2.
New to Docker? See Verifying your container for how to check it's running and handle port conflicts.
| Version | Status |
|---|---|
| PostgreSQL 17 | Stable |
| PostgreSQL 18 | Stable |
| PostgreSQL 19 | Experimental (beta -- supported until officially released) |
All extensions are built and tested against PG 17 and 18. Support for PG 19 is best-effort while it remains in beta; some extensions may not yet have upstream compatibility. Once PG 19 reaches GA, it will be promoted to stable.
| Extension | Version | PG versions | Description |
|---|---|---|---|
| age | 1.7.0 (PG17), 1.8.0 (PG18) | 17, 18 | Graph database with openCypher query language (Apache AGE) |
| anon | 3.1.1 | 17, 18 | Data anonymization and masking |
| credcheck | 5.0 | 17, 18, 19 | Credential checks on user creation / password change |
| db2fce | 0.0.17 | 17, 18 | DB2 compatibility functions (date/time, string helpers) |
| documentdb | 0.114-0 | 17, 18 | MongoDB-compatible document database engine (BSON types and CRUD API) |
| extra_window_functions | 1.0 | 17, 18, 19 | Extra window functions (ignore-nulls variants, nth-from-last) |
| first_last_agg | 0.1.4-4-gd63ea3b | 17, 18 | first() and last() aggregate functions |
| h3-pg | 4.2.3 | 17, 18 | Uber H3 hexagonal geospatial indexing |
| hll | 2.21 | 17, 18, 19 | HyperLogLog probabilistic distinct counting |
| http | 1.7.2 | 17, 18, 19 | HTTP client for PostgreSQL (web requests from SQL) |
| hypopg | 1.4.3 | 17, 18, 19 | Hypothetical indexes for what-if analysis |
| icu_ext | 1.11.0 | 17, 18, 19 | ICU functions: Unicode names, transliteration, spellout, collation |
| ip4r | 2.4.3 | 17, 18, 19 | IPv4/IPv6 range data types with GiST indexing |
| jsquery | 1.2 | 17, 18 | JSON query language with GIN indexing |
| orafce | 4.16.7 | 17, 18, 19 | Oracle compatibility functions and packages |
| periods | 1.2.3 | 17, 18 | SQL:2016 application-time PERIODs and system versioning |
| pg_background | 2.0.2 | 17, 18, 19 | Run SQL in background worker processes |
| pg_csv | 1.0.2 | 17, 18, 19 | Aggregate result rows into CSV text |
| pg_dirtyread | 2.8 | 17, 18, 19 | Read dead (deleted, unvacuumed) tuples for forensics/recovery |
| pg_pwhash | 1.0 | 17, 18, 19 | Password hashing (scrypt, argon2, yescrypt) |
| pg_show_plans | 2.1.8 | 17, 18, 19 | Show execution plans of all currently running queries |
| pg_statviz | 1.1 | 17, 18, 19 | Time-series snapshots of PostgreSQL statistics for visualization |
| pgaudit | 17.1 | 17, 18 | Audit logging (session and object-level) |
| pg_bigm | 1.2 | 17, 18 | 2-gram full text search (better for CJK languages) |
| pg_clickhouse | 0.10.0 | 17, 18 | Query ClickHouse databases from PostgreSQL (FDW with pushdown; depends on re2 for regex pushdown) |
| pg_cron | 1.6.7 | 17, 18 | Job scheduler (periodic jobs inside the database) |
| pg_duckdb | 1.1.1 | 17, 18 | DuckDB columnar analytics engine embedded in Postgres |
| pg_durable | 0.2.3 | 17, 18 | In-database durable execution (fault-tolerant workflows) |
| pg_failover_slots | 1.2.1 | 17, 18 | Logical replication slot manager for failover |
| pg_graphql | 1.6.1 | 17, 18 | GraphQL support for PostgreSQL |
| pg_hashids | 1.2.1 | 17, 18, 19 | Short unique hash IDs from integers |
| pg_hint_plan | 1.7.1 | 17, 18 | Tweak execution plans using hints in SQL comments |
| pg_ivm | 1.13 | 17, 18 | Incremental View Maintenance for materialized views |
| pg_jsonschema | 0.3.4 | 17, 18 | JSON Schema validation |
| pg_lake | 3.4.1 | 17 | Iceberg and data lake access (Parquet, CSV, JSON via DuckDB) |
| pg_net | 0.20.3 | 17, 18, 19 | Async non-blocking HTTP/HTTPS requests |
| pg_partman | 5.4.3 | 17, 18, 19 | Automated table partition management |
| pg_permissions | 1.4.1 | 17, 18, 19 | Review and audit object permissions against a desired state |
| pg_qualstats | 2.1.4 | 17, 18, 19 | Statistics collector for WHERE clause predicates |
| pg_re2 | 0.4.1 | 17, 18, 19 | ClickHouse-compatible regex functions using RE2 |
| pg_repack | 1.5.3 | 17, 18, 19 | Online table reorganization without heavy locks |
| pg_roaringbitmap | 1.2.0 | 17, 18 | Roaring bitmap data type for fast set operations |
| pg_rrule | 0.3.0 | 17, 18, 19 | iCalendar RRULE recurrence type and occurrence expansion |
| pg_similarity | 1.0 | 17, 18 | Similarity functions (Levenshtein, Jaro-Winkler, Cosine, Jaccard) |
| pg_squeeze | 1.9.3 | 17, 18, 19 | Remove unused space from tables without heavy locks |
| pg_stat_monitor | 2.3.2 | 17, 18 | Enhanced query statistics with histograms and buckets |
| pg_textsearch | 1.3.1 | 17, 18 | BM25 relevance-ranked full-text search |
| pg_uuidv7 | 1.7.0 | 17, 18, 19 | UUIDv7 generation (time-sortable unique identifiers) |
| pg_wait_sampling | 1.1.11 | 17, 18, 19 | Sampling-based statistics of wait events |
| pgfincore | 1.4.0 | 17, 18, 19 | Inspect and manage OS page cache for data files |
| pgjwt | master | 17, 18, 19 | JSON Web Token (JWT) generation and validation |
| pglogical | 2.4.7 | 17, 18, 19 | Logical streaming replication using publish/subscribe model |
| pgmq | 1.12.0 | 17, 18, 19 | Lightweight message queue on Postgres (like AWS SQS/RSMQ) |
| pgnodemx | 2.0.1 | 17, 18 | Expose node OS/cgroup metrics as SQL (container-aware monitoring) |
| pgpcre | 0.20190509 | 17, 18, 19 | Perl-compatible regular expression (PCRE) type and functions |
| pgrouting | 4.0.1 | 17, 18, 19 | Geospatial routing and network analysis on PostGIS |
| pgsodium | 3.1.11 | 17, 18, 19 | Modern cryptograph |
暂无开放 Issues,或尚未同步最近议题。