I had a set of services built with Docker Compose. In this set, I had a PostgreSQL service coupled with a PgBouncer instance that pooled requests from the other services of my application to the database. The PostgreSQL was at version 13 and I wanted to upgrade to the next version, at the time of this writing, 14.

The Docker Compose service settings initially looked like this:

The next version tag for the db service was 14-alpine. So I changed the docker-compose.yml respectively:

Once the new configuration is applied and the services are re-built and restarted I get the following error message:

The solution was to remove the database volume pg_data, re-build the service and restore the database backup.

The next problem, I’ve encountered was the incompatibility of the authentication method. The PgBouncer service I was running used md5 and I had these errors from the pgb service:

My solution was to change the authentication method on the PostgreSQL side, in my service db. To do that I needed to set the server setting password_encryption to md5. This can be done by adding the command line to the service settings in the file docker-compose.yaml:

Next, I needed the db service to use a custom file pg_hba.conf. In the project root, I created a copy of the original pg_hba.conf and modified the last line to use trust as METHOD. Originally the line looked like this:

After the modification the same line:

Finally, I mount the custom file as a volume to the service and tell PostgreSQL to use it instead of the default pg_hba.conf file:

The command section is in one line, with no line breaks.

I recreated the db container and the PgBouncer pooling service was now able to connect to the database.