The safest beginner environment is a version-pinned PostgreSQL container image that already includes pgvector. It avoids modifying your operating-system database and makes cleanup reproducible. You will connect with psql, enable the extension inside one learning database, verify versions, and keep credentials in environment variables rather than source code.
Lab: 20–35 minutes · Cost: free on your computer · Cleanup: remove the named container and volume shown below. Do not expose port 5432 to an untrusted network.
Use a pgvector image tag that exists for your platform and pin it in your learning repository. This example uses PostgreSQL 18; if your organization supports another current major version, change both the image and your compatibility tests.
For a shared repository, put the password in an uncommitted .env file and reference it from Compose. The literal above is acceptable only for an isolated local lab.
Inside psql:
Expected evidence is one vector row with an installed version and ai_native | learner. At the book verification date, upstream pgvector documentation references v0.8.6, but your pinned image determines the installed version.
Create an ignored local environment variable:
Never commit the URL. In production, obtain credentials from an approved secret manager and use TLS.
Follow upstream installation notes for Linux, macOS, or Windows rather than copying unverified build flags.
Run a disposable smoke test:
Expected: [1,2,3] and 3. A temporary table disappears when the session ends.
Given my OS [name/version] and CPU [architecture], produce a pgvector installation checklist using either Docker Compose or official upstream build instructions. Pin versions, explain where data persists, avoid public port binding, and include commands that print PostgreSQL and pgvector versions. Do not invent package names; link primary sources.
Verification contract: Accept the setup only after pg_isready, SELECT version(), the pg_extension query, and the temporary vector smoke test pass.