"SQLSTATE[HY000] [2002] Connection refused" during upgrade of previously working docker-compose setup

I am trying to get an existing Nextcloud Docker install back up and running (i.e., a configuration that previously worked) using the 23-fpm-alpine image (corresponds to 23.0.3 right now) and a MariaDB database (linuxserver/mariadb). However php occ upgrade fails with several SQLSTATE[HY000] [2002] Connection refused errors:

/var/www/html $ php occ upgrade -vvv
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
2022-04-16T14:19:04+00:00 Setting log level to debug
2022-04-16T14:19:04+00:00 Repair step: Repair MySQL collation
2022-04-16T14:19:04+00:00 Repair info: All tables already have the correct collation -> nothing to do
2022-04-16T14:19:04+00:00 Repair step: Repair SQLite autoincrement
2022-04-16T14:19:04+00:00 Repair step: Copy data from accounts table when migrating from ownCloud
2022-04-16T14:19:04+00:00 Repair step: Drop account terms table when migrating from ownCloud
2022-04-16T14:19:04+00:00 Updating database schema
2022-04-16T14:19:04+00:00 Updated database
2022-04-16T14:19:05+00:00 Repair step: Repair MySQL collation
2022-04-16T14:19:05+00:00 Repair info: All tables already have the correct collation -> nothing to do
2022-04-16T14:19:05+00:00 Repair step: Repair mime types
2022-04-16T14:19:05+00:00 Repair step: Clean tags and favorites
2022-04-16T14:19:05+00:00 Repair info: 0 tags of deleted users have been removed.
2022-04-16T14:19:05+00:00 Repair info: 0 tags for delete files have been removed.
2022-04-16T14:19:05+00:00 Repair info: 0 tag entries for deleted tags have been removed.
2022-04-16T14:19:05+00:00 Repair info: 0 tags with no entries have been removed.
2022-04-16T14:19:05+00:00 Repair step: Repair invalid shares
2022-04-16T14:19:05+00:00 Repair step: Move .step file of updater to backup location
2022-04-16T14:19:05+00:00 Repair step: Add move avatar background job
2022-04-16T14:19:05+00:00 Repair info: Repair step already executed
2022-04-16T14:19:05+00:00 Repair step: Add preview cleanup background jobs
2022-04-16T14:19:05+00:00 Repair step: Fix potential broken mount points
2022-04-16T14:19:05+00:00 Repair info: No mounts updated
2022-04-16T14:19:05+00:00 Repair step: Repair language codes
2022-04-16T14:19:05+00:00 Repair step: Install new core bundle components
2022-04-16T14:19:05+00:00 Repair step: Add log rotate job
2022-04-16T14:19:05+00:00 Repair step: Clear frontend caches
2022-04-16T14:19:05+00:00 Repair info: Image cache cleared
2022-04-16T14:19:05+00:00 Repair info: SCSS cache cleared
2022-04-16T14:19:05+00:00 Repair warning: Unable to clear the frontend cache
2022-04-16T14:19:05+00:00 Repair step: Clear every generated avatar on major updates
2022-04-16T14:19:05+00:00 Repair step: Add preview background cleanup job
2022-04-16T14:19:05+00:00 Repair error: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused
2022-04-16T14:19:05+00:00 Repair step: Queue a one-time job to cleanup old backups of the updater
2022-04-16T14:19:05+00:00 Repair error: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused
2022-04-16T14:19:05+00:00 Repair step: Cleanup invalid photocache files for carddav
2022-04-16T14:19:05+00:00 Repair step: Add background job to cleanup login flow v2 tokens
2022-04-16T14:19:05+00:00 Repair error: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused
2022-04-16T14:19:05+00:00 Repair step: Remove potentially over exposing share links
2022-04-16T14:19:05+00:00 Repair info: No need to remove link shares.
2022-04-16T14:19:05+00:00 Repair step: Clear access cache of projects
2022-04-16T14:19:05+00:00 Repair step: Reset generated avatar flag
2022-04-16T14:19:05+00:00 Repair step: Keep legacy encryption enabled
2022-04-16T14:19:05+00:00 Repair step: Check encryption key format
2022-04-16T14:19:05+00:00 Repair step: Remove old dashboard app config data
2022-04-16T14:19:06+00:00 Repair step: Add job to cleanup the bruteforce entries
2022-04-16T14:19:06+00:00 Repair error: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused
2022-04-16T14:19:06+00:00 Repair step: Queue a one-time job to check for user uploaded certificates
2022-04-16T14:19:06+00:00 Repair step: Repair DAV shares
2022-04-16T14:19:06+00:00 Repair step: Add background job to set the lookup server share state for users
2022-04-16T14:19:06+00:00 Repair error: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused
2022-04-16T14:19:06+00:00 Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused
2022-04-16T14:19:06+00:00 Update failed
2022-04-16T14:19:06+00:00 Maintenance mode is kept active
2022-04-16T14:19:06+00:00 Resetting log level

The error logs on the MariaDB server are empty. Local connections using mysql/mariadb work fine with the configured password and user, and the open port is visible from the Nextcloud-container:

/var/www/html $ nc -zv -w2 db 3306
db (172.19.0.5:3306) open

Suggestions?