Setting up Postgres container with persistent storage/host path storage

System info:

  • Scale Cobia
  • Official postgres:16.3 image running as custom app
  • UID/GID for postgres, has ownership over the dataset being used

Does anyone run a Postgres database instance and able to mount the db data to a Host Path successfully?

Need some help with my Homelab setup. Having an issue where it’s mounted under the directory I chose but not saving. I have some experience running containers in a Pi but moving my homelab setup to Truenas so I can use the Pi for other things. This is the last piece of the puzzle.

At the bare minimum I’d like to setup persistent data in case I need to restart the container.

I tried using /var/ as the mount path and other variations based on where the database data is stored using SHOW data_directory; in pgAdmin.

Or is the way to approach this to just use pgAdmin to create backups and restore whenever I restart the Postgres container?