Automatically upgrading PostgreSQL container with pgautoupgrade
The MariaDB container image has an upgrade option which will automatically upgrade system tables when switching to a newer version.
The PostgreSQL container image has no such option.
The reason is that it is a bit more involved to do so.
The pg_upgrade binary needs the binaries of the previous (current) version and the next version.
There are several options to accomplish this task.
One is to dump and restore the data via pg_dumpall.
However, doing this in production can lead to a long downtime depending on the size of the databases.
There are some additional container images that can help with this doing an in-place upgrade:
Backup your database first
Before doing anything, it is crucial to backup your databases first so you can restore if anything goes wrong.
I tried them both and found pgautoupgrade to be the easiest.