Setting up cron job in AIO docker container

I am trying to setup cronjob, primarily to run occ preview:pre-generate every 1 hr. I have a NextCloud installed through docker nextcloud/all-in-one:latest image as explained in the official doc. This has spawned several containers – for DB, main instance, talk, borg, etc.

I did come across this topic: Nextcloud Docker Container - best way to run cron job - #6 by disgustipated

However, the suggestion in that thread is to set up a new container specific to cron job through docker-compose. However, since i didn’t setup my NC docker containers individually or through docker-compose, I’m not exactly sure how to do it the right way. I am assuming all-in-one image runs some script that uses docker-compose (or similar) underneath?

In the NC admin console, I did see that the cron.php is getting executed every 5 mins. How is that? If there is already a cron job configured to run cron.php I would very much like to add one additional command to the cron job list.

The easiest way so far i found is to setup a crontab on my host, which I prefer not to. I’m trying to setup a portable system and build my own docker-compose file that spawns off master-container + sets up a trasncoder container for memories app, for future-proofing.

edit nm, sorry i see now that you specifically dont want to do that. i have no input here lol
my post is the one you linked to, which i was referencing this post. this post details how to not use another container to run a command. doing it this way is the best way. you set up cron on the host to run the command in the container. notice the docker exec command used in the cron line.

1 Like