Files
postgres-ts-vectors/README.md
Maxime Killinger f0d5f4870e
All checks were successful
🚀 Docker Build and Push / build-and-push (15) (push) Successful in 4m44s
🚀 Docker Build and Push / build-and-push (16) (push) Successful in 4m48s
🚀 Docker Build and Push / build-and-push (17) (push) Successful in 4m47s
🚀 Docker Build and Push / build-and-push (18) (push) Successful in 4m36s
fix(docker): resolve permission denied error for PG18+ volume mounts
PostgreSQL 18+ Docker images changed the data directory structure to use
versioned subdirectories (e.g., /var/lib/postgresql/18/main) instead of
the traditional /var/lib/postgresql/data path.

Changes:
- Dockerfile: Add mkdir and chown to ensure /var/lib/postgresql has
  correct permissions for the postgres user before volume mount
- README.md: Update Quick Start with volume mount example
- README.md: Add 'Data Persistence' section explaining PG18+ requirements

This fixes the 'mkdir: cannot create directory: Permission denied' error
that occurred when mounting volumes at /var/lib/postgresql.

See: https://github.com/docker-library/postgres/pull/1259
2025-12-25 17:32:43 +01:00

2.8 KiB

TimescaleDB + VectorChord + pgvector

Build Status

Docker image combining PostgreSQL with three powerful extensions:

  • TimescaleDB - Time-series database extension
  • VectorChord - High-performance vector similarity search
  • pgvector - Open-source vector similarity search

Supported PostgreSQL Versions

Tag PostgreSQL TimescaleDB VectorChord pgvector
pg15 15 2.24.0 1.0.0 0.8.1
pg16 16 2.24.0 1.0.0 0.8.1
pg17 17 2.24.0 1.0.0 0.8.1
pg18, latest 18 2.24.0 1.0.0 0.8.1

Quick Start

docker run -d \
  --name my-postgres \
  -e POSTGRES_PASSWORD=mysecretpassword \
  -v postgres_data:/var/lib/postgresql \
  -p 5432:5432 \
  gitea.killinger.fr/maxime.killinger/postgres-ts-vectors:latest

All extensions are automatically created on first startup.

Data Persistence

Important

Starting with PostgreSQL 18, mount volumes at /var/lib/postgresql (not /var/lib/postgresql/data). Data will be stored in a versioned subdirectory (e.g., /var/lib/postgresql/18/main), which facilitates future upgrades with pg_upgrade.

Environment Variables

Variable Description Default
POSTGRES_PASSWORD PostgreSQL password (required) -
POSTGRES_USER PostgreSQL user postgres
POSTGRES_DB Default database postgres

Extensions Usage

TimescaleDB

-- Create a hypertable
CREATE TABLE conditions (
  time TIMESTAMPTZ NOT NULL,
  device_id INTEGER,
  temperature DOUBLE PRECISION
);

SELECT create_hypertable('conditions', 'time');

VectorChord / pgvector

-- Create a table with vector embeddings
CREATE TABLE documents (
  id SERIAL PRIMARY KEY,
  content TEXT,
  embedding vector(1536)
);

-- Create an index for fast similarity search
CREATE INDEX ON documents USING vchordrq (embedding vector_l2_ops);

-- Query similar documents
SELECT * FROM documents
ORDER BY embedding <-> '[0.1, 0.2, ...]'
LIMIT 10;

Building Locally

# Build for PG18
docker build --build-arg PG_VERSION=18 -t my-image:pg18 .

# Build for PG16
docker build --build-arg PG_VERSION=16 -t my-image:pg16 .

License

This project is licensed under the Apache 2.0 License.