Cron for Nextcloud in Docker

AJAX wasn't cutting it, traditional crontab in containers doesn't make much sense to me, webcron is recommended but I don't want to register with anything outside my LAN... Turns out you can just spin up an identical container with a different entrypoint to /cron.sh that does what you need!

Note that this is a task in an Ansible playbook - but the docker-compose is straight forward

So the only thing you need to make sure of is that all the configuration options - data volumes, user permissions, etc. are identical between the containers running the cron job and the one actually hosting NextCloud. This ensures that the container running cron has proper access to the database and filesystem - or at least the same access as NextCloud proper.

- name: Nextcloud Cron Docker Container
  docker_container:
    name: nextcloud-cron
    image: ""
    pull: true
    links:
      - nextcloud-mysql:mysql
    entrypoint: /cron.sh
    volumes:
      - "/nextcloud:/var/www/html:rw"
    env:
      MYSQL_HOST: "mysql"
      MYSQL_DATABASE: "nextcloud"
      MYSQL_USER: ""
      MYSQL_PASSWORD: ""
      NEXTCLOUD_TRUSTED_DOMAINS: "."
      PUID: ""
      PGID: ""
      TZ: ""
    restart_policy: unless-stopped
    memory: ""