Postgres 17 image with multi-db, user, and pgvector (0.7.1) auto-setup via env variables.
1.6K
This image extends the official Postgres image to support:
pgvector extension for databases prefixed with VECTOR_gettext/envsubst for dynamic templatingVECTOR_, the pgvector extension is enabled in that database.<db>_user (all lowercase) and a default password.postgres-pgvector-multidatabase/
├── Dockerfile # Docker build instructions for the custom Postgres image
├── init-multidb.sh # Initialization script for dynamic multi-database and user setup
├── init.sql.template # SQL template used for database/user creation and extension enabling
├── LICENSE.md # Project license (MIT)
├── README.md # Project documentation and usage instructions
docker build -t custom-postgres-multidb-pgvector .
docker run -d \
--name my-postgres \
-e POSTGRES_USER=pguser \
-e POSTGRES_PASSWORD=pguserstrongpassword \
-e POSTGRES_DB=postgres \
-e POSTGRES_DB_SIDECARS=db1,db2,VECTOR_db3 \
-p 5432:5432 \
custom-postgres-multidb-pgvector
You can adjust the environment variables as needed.
A prebuilt image is available on Docker Hub:
luismachadoreis/postgres-multidb-pgvector:pg17
pg17 tag for AMD64 (x86_64) systems:
docker pull luismachadoreis/postgres-multidb-pgvector:pg17
pg17-arm64 tag for ARM64 (Apple Silicon, Raspberry Pi, etc):
docker pull luismachadoreis/postgres-multidb-pgvector:pg17-arm64
You can use the appropriate image in your docker run or docker-compose.yml as the base image for your platform.
version: '3.8'
services:
postgres:
build: .
environment:
POSTGRES_USER: pguser
POSTGRES_PASSWORD: pguserstrongpassword
POSTGRES_DB: postgres
POSTGRES_DB_SIDECARS: db1,db2,VECTOR_db3
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:
| Variable | Default | Description |
|---|---|---|
POSTGRES_USER | pguser | Default user role (as in official image) |
POSTGRES_PASSWORD | pguserstrongpassword | Password for the default user |
POSTGRES_DB | postgres | Default database (as in official image) |
POSTGRES_DB_SIDECARS | db1,db2,VECTOR_db3 | Comma-separated list of extra databases to create |
POSTGRES_DB_SIDECARS:
<db>_user (all lowercase), password: mydefaultpasswordVECTOR_, the pgvector extension is enabled in that databaseinit-multidb.sh runs.VECTOR_, it enables the pgvector extension.mydefaultpassword (change in script if needed).You can override any environment variable at build or runtime. For example, to add more vector-enabled databases:
POSTGRES_DB_SIDECARS: db1,VECTOR_embeddings,VECTOR_analytics
pgvector extension is built from source at image build time.git clone [email protected]:luismr/postgres-17-multidb-pgvector.git
cd postgres-17-multidb-pgvector
git checkout -b my-feature-branch
git push origin my-feature-branch
main branch of this repository.Content type
Image
Digest
sha256:3f787d8ec…
Size
486.7 MB
Last updated
over 1 year ago
docker pull luismachadoreis/postgres-multidb-pgvector