Sign inSign up

jeffh/postgres

By jeffh

•Updated 7 months ago

Postgres with extensions

Image
Databases & storage
0

5.9K

jeffh/postgres repository overview

⁠PostgreSQL Docker Image

Custom PostgreSQL image with pre-installed extensions for search, geospatial, vector, and job scheduling.

⁠Supported PostgreSQL Versions

VersionTags
1818, latest
1717
1616

⁠Installed Extensions

ExtensionSourcePG VersionsNotes
pg_searchParadeDB image16, 17, 18BM25 full-text search (ParadeDB)
pg_ivmParadeDB image16, 17, 18Incremental view maintenance
pgvectorAPT (latest)16, 17, 18Vector similarity search
PostGIS 3APT (latest)16, 17, 18Geospatial database (+ topology, geocoder)
pg_cronAPT (latest)16, 17, 18Job scheduler (postgres DB only)
pg_textsearchGitHub release 0.5.017, 18BM25 ranked text search (Timescale); manual CREATE EXTENSION required — conflicts with pg_search
fuzzystrmatchPostgreSQL contrib16, 17, 18Fuzzy string matching
pg_stat_statementsPostgreSQL contrib16, 17, 18Query performance statistics (preloaded)

⁠Build Args

ArgDefaultDescription
PG_VERSION_MAJOR17PostgreSQL major version
PG_TEXTSEARCH_VERSION0.5.0pg_textsearch release version

⁠Building

docker build --build-arg PG_VERSION_MAJOR=17 -t postgres:17 postgres/

Most extensions are auto-created in template1 and $POSTGRES_DB at first startup. pg_textsearch must be created manually (CREATE EXTENSION pg_textsearch;) because it conflicts with pg_search's BM25 access method.

⁠Running

docker run -d \
  --name postgres \
  -e POSTGRES_USER=myuser \
  -e POSTGRES_PASSWORD=mypassword \
  -e POSTGRES_DB=mydb \
  -v pgdata:/var/lib/postgresql/data \
  -p 5432:5432 \
  postgres:17

⁠Environment Variables

These are inherited from the official postgres⁠ base image. This image does not add any custom environment variables.

VariableDefaultDescription
POSTGRES_PASSWORD(required)Superuser password
POSTGRES_USERpostgresSuperuser username
POSTGRES_DBvalue of POSTGRES_USERDefault database created at startup
PGDATA/var/lib/postgresql/dataData directory inside the container

⁠Volumes

PathPurpose
/var/lib/postgresql/dataDatabase storage. Mount a named volume or bind mount to persist data.
/docker-entrypoint-initdb.d/Initialization scripts that run once on first startup (see below).

⁠Custom Initialization SQL

To run your own SQL or shell scripts when the database is first created, mount them into /docker-entrypoint-initdb.d/:

docker run -d \
  -e POSTGRES_PASSWORD=mypassword \
  -v pgdata:/var/lib/postgresql/data \
  -v ./my-init-scripts:/docker-entrypoint-initdb.d/ \
  postgres:17

Scripts are executed in alphabetical order. This image ships 001-create-paradedb-extensions.sh, which creates the bundled extensions. Use a higher numeric prefix (e.g. 100-my-setup.sql) so your scripts run after the extensions are ready.

Both .sql and .sh files are supported. These scripts only run on the first startup — when the data directory is empty. If you need to run migrations on an existing database, use psql or a migration tool instead.

To enable pg_textsearch (which conflicts with pg_search), create it manually in your init script:

-- 100-enable-textsearch.sql
CREATE EXTENSION IF NOT EXISTS pg_textsearch;

Tag summary

Content type

Image

Digest

sha256:211e87226…

Size

492.6 MB

Last updated

7 months ago

docker pull jeffh/postgres