Store relational data, vectors, and graphs in PostgreSQL 18 with pgvector and Apache AGE.
1.2K
Store relational data, vectors, and graphs in PostgreSQL 18 with pgvector and Apache AGE.
You learn to use postgres-vector-graph in a Docker container.
pg_trgm, btree_gin, and uuid-osspCreate each extension in the database where you use it. PostgreSQL starts with its normal
postgres command. The image keeps the official PostgreSQL initialization behavior.
| Tag | Meaning | Platform |
|---|---|---|
latest | Latest successful main build | linux/amd64 |
change-me is a placeholder password. Replace it before you use the database.
PostgreSQL 18 stores data under /var/lib/postgresql. Mount the volume at that path.
docker pull stden/postgres-vector-graph:latest
docker run -d --name docker-gems-graph \
-p 127.0.0.1:5432:5432 \
-e POSTGRES_PASSWORD=change-me \
-v docker-gems-graph-data:/var/lib/postgresql \
stden/postgres-vector-graph:latest
Wait for the server to accept TCP connections. During the initialization, a temporary server accepts only socket connections. Run this check in Bash:
(
for attempt in {1..60}; do
if docker exec docker-gems-graph pg_isready -h 127.0.0.1 -U postgres; then
exit 0
fi
sleep 2
done
docker logs docker-gems-graph
echo "PostgreSQL did not become ready." >&2
exit 1
)
Continue only when the readiness check succeeds. Enable the extensions and run the sample queries:
docker exec -i docker-gems-graph psql -U postgres -d postgres \
--no-psqlrc --set ON_ERROR_STOP=1 <<'SQL'
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS age;
SELECT '[1,2,3]'::vector <-> '[1,2,4]'::vector AS distance;
LOAD 'age';
SET search_path = ag_catalog, public;
SELECT create_graph('demo');
SELECT * FROM cypher('demo', $$ CREATE (:Item {name: 'Docker'}) $$) AS (result agtype);
SELECT * FROM cypher('demo', $$ MATCH (n:Item) RETURN n.name $$) AS (name agtype);
SQL
Run create_graph('demo') only once in each database. For later Cypher sessions, run
LOAD 'age'. Then set the search path again. Use docker stop docker-gems-graph to stop the
container. The named volume keeps the data.
CI starts a temporary cluster as the postgres user. It checks that the extensions load.
It also checks the vector distance and the Cypher results. The test never connects to an
existing database.
Dockerfile · Smoke test · Docker tutorial · Build results
Content type
Image
Digest
sha256:58decd34b…
Size
163.9 MB
Last updated
1 day ago
docker pull stden/postgres-vector-graph