pgvector
What is pgvector?
pgvector is a PostgreSQL extension that adds vector similarity search, the standard building block for AI/RAG features (storing and querying embeddings). Laradock runs this as a separate Postgres instance built from the official pgvector/pgvector image, with its own port and data folder so it can run alongside the regular postgres service without conflicting.
Start pgvector
docker compose up -d pgvector
Stop pgvector
docker compose stop pgvector
This stops the container without deleting its data. Data lives under DATA_PATH_HOST/pgvector.
Configuration
All settings live in pgvector/defaults.env and can be overridden by adding the same line to your own .env:
| Variable | Default | What it does |
|---|---|---|
PGVECTOR_VERSION | pg17 | Image tag from pgvector's Docker Hub image, matches the underlying Postgres major version. |
PGVECTOR_PORT | 5433 | Host-side port (container port 5432), deliberately different from the regular postgres service's 5432 so both can run at once. |
PGVECTOR_DB | default | Database created automatically on first boot; the vector extension is enabled in this database automatically. |
PGVECTOR_USER | default | Non-root user created automatically. |
PGVECTOR_PASSWORD | secret | Password for PGVECTOR_USER. |
PGVECTOR_ENTRYPOINT_INITDB | ./pgvector/docker-entrypoint-initdb.d | Folder of init scripts auto-run on first boot, this is where CREATE EXTENSION vector happens (init.sql). |
Connect from your host machine
Connect to localhost on PGVECTOR_PORT (5433 by default) with PGVECTOR_USER/PGVECTOR_PASSWORD, using any Postgres client (psql, TablePlus, DBeaver):
psql -h localhost -p 5433 -U default -d default
From another Laradock container, use DB_HOST=pgvector and port 5432 (the container-internal port).
Verify the extension is enabled
docker compose exec pgvector psql -U default -d default -c "SELECT * FROM pg_extension WHERE extname = 'vector';"
Common issues
vectorextension missing. It's enabled bypgvector/docker-entrypoint-initdb.d/init.sql, which only runs the first time the data folder is created. If you changedPGVECTOR_DBafter the volume already existed, connect and runCREATE EXTENSION IF NOT EXISTS vector;manually.- Confusing this with the regular
postgresservice. They're two separate containers with separate ports (5433vs5432) and separate data folders (DATA_PATH_HOST/pgvectorvsDATA_PATH_HOST/postgres), on purpose, so you can run both. - Port already in use on your host. Change
PGVECTOR_PORTin.envand restart:docker compose up -d pgvector. - App can't connect but the container is running. From inside another container, the host is
pgvectorand the port is the container-internal5432, notPGVECTOR_PORT.
Need plain Postgres without vectors? See the Databases guide. Back to the Getting Started guide.