I’ve read a bunch of threads on how to get cron.php running in the docker image. Reading through the manual, I see that systemd timers are supported. The docker image already uses systemd. Why not just add systemctl to the image and then have the two timer files already in /etc/systemd/system. Then with one command line you can enable the cron job, or you can find a way to do it from the GUI.
My answer here is not specific to Nextcloud but general.
First, when you are thinking docker, you must do so whole-heartedly. When there are multiple concerns (PHP processing and cron jobs), there should be multiple docker containers. This is the reason why most of the important docker images are not containing a service manager (like sysinit, upstart, systemd,…).
There might be legit reasons when a container is running multiple processes. This is e.g. the case when there is a master process and multiple workers. Only a few users try to reverse this and use containers a VMs (as full-fledged Linux instances).
Especially, when you are providing an image for others (potentially professional users), be sure to stick with the Dos and Don’ts.
Just a few points that might cause issues related to the Nextcloud installation bundled with systemd+cron:
- How to leverage the rights to allow the
www-datauser to access the systemd timers or crontabs (access rights!)? Do you want to grant root rights?!?
- What happens when you have multiple PHP containers? Each one will trigger the cron runs. How to tackle this?
- How to handle the same effect when using the server in a non-docker container? Should the
www-datauser be allowed to
sudoon a production system without any sort of sandbox ?
So, you need to keep the whole picture in mind.