Mariadb container reliability?

Hello, I’m coming in with a bit of vague question to start with here, but I am happy to provide further technical details if I’m not just barking up the wrong tree.

Anyway, I’m running a whole bunch of containers behind SWAG on a home LAN and they generally just run absolutely fine with very little intervention needed. The ‘server’ they are running on ls made up of consumer-grade hardware which includes:

  • AMD Ryzen 3 1200
  • 32GB ECC RAM
  • single SSD formatted with BTRFS for root
  • all other storage on a ZFS RAIDZ1 array of 5 HDDs (this is also where the docker containers’ persistent data lives).

Ubuntu 20.04 LTS is the OS and the machine is almost never overloaded in terms of CPU, RAM or networking. It’s a home server, serving 4 users and rarely all 4 at the same time.

Now the machine is very reliable, whether that be the containers or anything running on the host OS, with the exception of the two containers which rely on their own separate instances of the mariadb container. They are

  • Nextcloud (docker: nextcloud )
  • FreePBX (docker: tiredofit/freepbx )

and these two require intervention every few weeks because something invariably happens to them causes their respective databases to fail.

Nextcloud will usually accumulate database table errors when, for example, multiple files are simultaneously renamed/moved/deleted on a synced client. I have been able to ‘repair’ this each time it’s happened so far because I seem to have got lucky with the damage being limited to tables that nextcloud seems happy to repopulate after I’ve crudely TRUNCATEd them to remove the damage.

FreePBX however, will suffer a catastrophic, unrecoverable (at least for my skill level) database failure whenever it decides to fail that requires me to tear the container down, rebuild it afresh and restore my particular configuration from a known-good FreePBX backup I have. Last week, it was simply trying to generate a CDR report for September that caused it to totally sh*t the bed.

Can anyone think of reasons why the databases for these two containerised applications are so fragile? I’m at a loss to explain it. I ran nextcloud on the host OS for years without issues like this. Similarly I ran FreePBX (IncrediblePBX) for years in a VirtualBox VM just fine. It’s only when I’ve moved these applications to containers that I’ve run into serious and repeated database issues.

Are there best practices for running containerised databases I don’t know about? Are there minimum hardware specs I don’t satisfy with my setup? Am I doing containerisation wrong somehow? I think I’m pretty close to the typical SWAG setup and docker run commands for everything.

Anyway, it’s midnight now and I’ll provide more technical details tomorrow if someone can give me some direction on where to focus my troubleshooting efforts…

thanks, Richard