I use the joplin server docker container, I have followed the setup guide listed here:
Every few weeks or months it always dies, I assume there's an out of memory issue somewhere but not sure what's happening.
Has anyone else had this problem? If so are there some steps I can diagnose this issue with?
Here is the log output before it died (it's always the same error message)
I'd be interested to know why as well. We had this issue a few times on Joplin Cloud too although we have it setup to reboot automatically so it's not a massive problem, but would still be nice to understand why it happens.
Your memory usage at 930MB seems fine and is not over the limit anyway so it should not crash the container. I found that logs in that situation tell pretty much nothing, whether it's the system one or Docker one but if you find anything please share back.
I imagine it's the Docker snap in your case, yeah. The system attempts to restart services, but the high level service for Docker is the Docker service itself, not whatever you're using Docker for (Joplin), the updater feels like it's successfuly done a full restart of the environment, but simply just doesn't, you'd likely need to augment it somehow so the Docker service has a concept of default containers to run when it boots, assuming this exists.
(sudo snap refresh --hold=forever docker - if you wanted to disable the updates)
Coincidentally, I was just talking to a friend about an older project I never finished, putting the Joplin Server itself into a snap, it was pretty damn functional at the point I remember working on it; you'd see snap here would actually see the high level service as Joplin (and Caddy) themselves, and if snapd were to reboot a Joplin-Server snap, it'd explicitly reboot the Joplin Server environment too, because it can see that's the real target.
The Joplin Cloud environment might be running Docker as a snap, but for now, I'd assume that isn't the case, but the snap update system does seem to be your specific problem there.
Edit: Start containers automatically | Docker Docs looks relevant if you wanted to keep Docker updating automatically but minimise the downtime, you'd be able to do things like tell snapd to only apply the update overnight when you're not using the system too with Refresh Timers like e.g., sudo snap set system refresh.timer=2:00-5:00, conceptually you'd still be "randomly rebooting" (for Docker patches) at the same rate but you'd shift that downtime to when you're not noticing it and make the restart automatic, so in theory you'd have a 30 seconds a month with zero involvement at a time you won't even notice kind of deal)
So I've removed the snap version of docker, and reinstalled docker using the apt-get method. I will see how that goes and report back here if there's any issues still happening, but fingers crossed that was it.
You still run the risk of it doing the same, it'll just be when unattended-upgrades upgrades Docker rather than Snap. The underlying problem is Docker (or systemd, alternatively) not being told to restart the containers which is the same for either scenario, the reduced updates would reduce the frequency but not avoid it entirely.
But for sure, I imagine you'll get significantly less updates, so you should notice it less, but you'd still notice it from time to time unless you did the Docker automatic restarts at the container level because when Apt eventually does upgrade Docker, it wouldn't restart Joplin either.
(Of course that assumes you have unattended upgrades on, but it usually is by default, if it isn't though, it's all manual and you would avoid it)