Live data from Hacker News

A PostgreSQL Docker container that automatically upgrades your database

github.com

1–10 of 93 posts

Re: A PostgreSQL Docker container that automatically upgrades your database

#3
post #2

Just to be clear, this isn't for actually running postgres to serve your database, right? This is just more or less a tool to upgrade your data files to a new postgres version?

It does both. As part of the startup process it first checks if the data files are for an old version, and upgrades them first (if needed).

Then it starts PostgreSQL 15.3 as per normal.

It's intended as being a drop-in replacement for existing (alpine based) PostgreSQL containers.

That being said, it's still pretty new so don't use it on production data until you've tested it first (etc).

--

Btw, it uses the "--link" option when it runs pg_upgrade so should be reasonably suitable even for databases of a fairly large size. That option means it processes the database files "in place" to avoid needing to make a 2nd copy.

At the moment it only process a single data directory, so if you have multiple then it's not yet suitable.

Re: A PostgreSQL Docker container that automatically upgrades your database

#6

Related: https://github.com/tianon/docker-postgres-upgrade

This one seems like a good proof of concept, but appears to need running as a separate task for upgrading rather than being an "automatic upgrade before starting the database server" thing?

Re: A PostgreSQL Docker container that automatically upgrades your database

#8

I have always wondered how a database and its persistence is handled in a containerized environment. This covers one of the issues.

With PostgreSQL containers used in docker-compose, the common approach is to use a bind mount so the database files are persisted on the host.

I've not done stuff with kubernetes yet though, so I have no idea how it's done there.

Re: A PostgreSQL Docker container that automatically upgrades your database

#9

I have always wondered how a database and its persistence is handled in a containerized environment. This covers one of the issues.

The way you handle persistence is by using storage volumes mounted form the outside. Don't put the data in the container, only the software, which then can be replaced. Then managing is similar to other environments. For updating you don't replace rpm/deb packages and restart, but replace the container using the same volume, which should trigger the dbms-specific update routine. Similarly you do backups similar to outside container world (depending on DBMS and your exact choice, from filesystem snapshot to logical backup (dump) or something more or less smart in between)

Re: A PostgreSQL Docker container that automatically upgrades your database

#10

I have always wondered how a database and its persistence is handled in a containerized environment. This covers one of the issues.

With PostgreSQL containers used in docker-compose, the common approach is to use a bind mount so the database files are persisted on the host. I've not done stuff with kubernetes yet though, so I have no idea how it's done there.

Both Docker and Kubernetes can use volumes to provide persistant storage to containers/pods without bind mount.
Post reply on HN