Installing PostgreSQL Server

To add to what others have said: You want to use a container. And the best tool to deploy a postgresql server on Bluefin is to use a quadlet which allows you to run a postgres server as a regular user (no root required).

The following is a spontaneous tutorial how to set up a postgres quadlet on Bluefin.

Create the following directory if it doesn’t exist already:

mkdir -p ~/.config/containers/systemd
cd ~/.config/containers/systemd

We will use the latest version of postgres which is postgres 17. Every major version of postgres has a different binary format, which is why you need to be explicit about the version that you use.

You need to create 3 files in the directory:

  • postgres17.container
  • postgres17 .volume
  • postgres17.env

The file postgres17.container should have the following contents:

[Unit]
Description=Postgres 17 server

[Container]
Image=docker.io/library/postgres:17
ContainerName=postgres17
PublishPort=5432:5432
Network=host
Volume=postgres17.volume:/var/lib/postgresql/data:z
EnvironmentFile=postgres17.env

[Install]
RequiredBy=default.target

And the file postgres17.volume should have the following contents:

[Unit]
Description=postgres 17 data

[Volume]
# default options are probably fine

And finally you need to create the file postgres17.env which should contain the password you want to use for the postgres user:

POSTGRES_PASSWORD=mysecretpassword

You can find more useful environment variables in the official docker image docs.

Finally run

systemctl --user daemon-reload
systemctl --user start postgres17

And your container will be available on your local machine listening on port 5432.

To connect to the server you need to use the URL postgres://postgres@localhost. If you only run psql it won’t find the server, because there is no socket on the host to connect to. You can also run

podman exec -itu postgres postgres17 psql

to interact directly with the database in the container.

5 Likes