PostgreSQL 17 + pgvector on Plesk (Docker): A Practical Setup Guide

TL;DR: Build a small derived Docker image that layers the pgvector extension onto the official postgres:17 image, deploy it with the Plesk Docker extension, persist data to the host, then CREATE EXTENSION vector; in your database. You’ll be up and running in minutes—with clean upgrades, backups, and security baked in.


 

What You’ll Build

  • A PostgreSQL 17 container on a Plesk server (Ubuntu 22.04 assumed)
  • The pgvector extension installed and available to all databases
  • Persistent storage on the host at /var/lib/postgres/pg17-data
  • A repeatable, pinned build (no “latest” surprises)

Estimated time: 20–30 minutes


 

Prerequisites

  • Plesk Obsidian with the Docker extension installed
  • SSH access with sudo privileges
  • Docker engine available on the host
  • Basic familiarity with Plesk’s Docker UI (Add Container, environment variables, volumes, ports)

Why a derived image? We pin the Postgres major version and the pgvector version for reproducibility and security. You can rebuild the image at any time and know exactly what you’re getting.


 

Step 1 — Create the Derived Image (PostgreSQL 17 + pgvector)

Create a new directory on the server (e.g., /root/pgvector-build/) and add this Dockerfile:

Build it:

Alternative: Use the prebuilt ankane/pgvector:pg17 image. It’s great for quick starts. A custom derived image is handy if you want precise control or to layer in org-specific defaults.


 

Step 2 — Prepare Persistent Storage on the Host

Create a directory for your Postgres data and fix ownership/permissions for the container’s postgres user (uid/gid 999):

Why here? /var/lib/postgres keeps things tidy and separate from other service data. You can back this directory up with your normal server backups/snapshots.


 

Step 3 — Deploy the Container via Plesk

  1. In Plesk, go to Server Management → Docker → Add Container.
  2. Image: choose your local image postgres:17-pgvector-0.7.4 (click Refresh if you don’t see it yet).
  3. Environment variables:
    • POSTGRES_PASSWORD=yourStrongPassword
    • (optional) POSTGRES_USER=appuser
    • (optional) POSTGRES_DB=appdb
    • (optional) TZ=America/New_York
  4. Volumes:
    • Host: /var/lib/postgres/pg17-data → Container: /var/lib/postgresql/data
  5. Ports: map container 5432/tcp to a host port. Use 5432 if free, or 5433 if 5432 is busy.
  6. Restart policy: enable Start after system reboot (or Restart: always).
  7. Click OK to create the container.

Security tip: If apps live on the same host, restrict external access with your firewall (see Step 6). Plesk’s port mapping typically binds to all interfaces.


 

Step 4 — Verify PostgreSQL and Enable pgvector

Install a client on the host if needed:

Connect and enable pgvector:

Check availability details:

If pg_available_extensions doesn’t list vector, the image wasn’t built correctly. See Troubleshooting.


 

Step 5 — Quick Functional Test (Vectors IRL)

Run a tiny demo to confirm the type and index work:


 

Step 6 — Secure the Port

If external clients don’t need direct access, lock it down with UFW:

For multi-tenant hosts, also consider VPC firewalls / security groups upstream of the server.


 

Step 7 — Backups & Restores

Host-based tools (recommended):

From inside the container:

For full-instance backups, add regular volume snapshots (e.g., EBS, LVM, ZFS) to your playbook for fast rollback.


 

Step 8 — Operations Cheatsheet

  • Logs: Plesk → Docker → your container → Logs (or docker logs <name>)
  • Change config: edit files under /var/lib/postgres/pg17-data/ (postgresql.conf, pg_hba.conf), then restart the container from Plesk
  • Minor upgrades: rebuild/pull a newer postgres:17-pgvector-*, stop container, start a new one with the same data volume
  • Major upgrades (17→18): use pg_dump/pg_restore or pg_upgrade procedure—not just an image swap

 

Troubleshooting

Address already in use (5432): pick another host port (e.g., 5433) or free 5432.

Data directory ownership/permissions error:

vector not available in pg_available_extensions: The image likely didn’t compile/install pgvector. Verify the files exist in the container:

Rebuild the image and ensure the build step isn’t failing.

CREATE EXTENSION vector; fails with permission/role errors: Connect as a superuser (default is postgres) or grant the necessary privileges.

Connection refused/timeouts: Check Plesk port mapping, host firewall, and container logs.


 

Variations & Tips

  • Prebuilt image: ankane/pgvector:pg17 is a solid alternative if you don’t need a custom build.
  • Pin your versions: Keep PG_MAJOR and PGVECTOR_VERSION pinned to avoid surprise upgrades.
  • Time zone: Set TZ to keep logs and timestamps consistent.

 

Alternative: Use a Prebuilt Image (ankane/pgvector:pg17)

  1. In Plesk, Add Container.
  2. Image: ankane/pgvector:pg17.
  3. Environment variables, volume, and ports: set exactly as in Step 3.
  4. Start the container, then connect to your database and run CREATE EXTENSION vector;.

Fastest path if you don’t need a custom build. For pinned versions and internal security reviews, prefer the derived image above.


 

Wrap-Up

You now have a clean, reproducible PostgreSQL 17 + pgvector stack running under Plesk’s Docker extension—with persistent storage, straightforward upgrades, and a secure posture. From here, wire your applications to the database and start building semantic search, RAG, recommendations, and more.


 

Need Help?

Reliable Penguin provides systems administration and managed hosting services. We can:

  • Build and harden PostgreSQL 17 + pgvector containers under Plesk
  • Configure secure networking (firewalling, port binding, TLS where applicable)
  • Set up monitoring, alerting, and centralized logs
  • Design and test backup/restore + disaster-recovery plans
  • Plan and execute version upgrades and migrations
  • Tune performance (parameters, I/O, indexing strategy guidance) and right-size resources
  • Implement high availability/failover architectures
  • Document the stack and provide runbooks; offer on-call/24×7 support options

Note: We don’t build application features. For app-level vector usage, we’re happy to coordinate with your dev team to ensure the platform is ready and well-supported.

Want this in production fast and stable? Get in touch and we’ll handle the infrastructure so your team can focus on the application.

Have a project or a problem?

Talk with a senior engineer for practical recommendations—no obligation.

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.