Nextcloud Docker Container - best way to run cron job

Nextcloud Docker Container - best way to run cron job

I have been doing some test setups of running NextCloud in a docker container. One thing I am still a little confused on and would like to hear your thoughts about, is running the cron process. I am a little surprised that it is not the default, but I found two methods of running the cron job in a container.

The first is from Docker Hub NextCloud examples (docker/.examples at master · nextcloud/docker · GitHub). It “uses supervisor to run the cron job inside the container (so no extra container is needed). This image runs supervisord to start nextcloud and cron as two seperate processes inside the container.” This requires a custom image build (docker/Dockerfile at master · nextcloud/docker · GitHub). Other than that it is not complicated.

The second I found is also from the examples
(docker/.examples/docker-compose/with-nginx-proxy/mariadb/apache at master · nextcloud/docker · GitHub). It is not explained well, but I believe they are just running a second NextCloud container to run the cron job. I am guessing this works because both containers use the same database and document store? Not sure about that.

My questions are:
What is the best way to run the cron job? (in regards to efficiency, ease of backups and restores, etc)
Is one an older way and the examples have just not been updated yet?

Thanks for your thoughts on this.

hello @John2 welcome back in the forum :handshake:

Please use the search - lot of issues have been discussed already like

there are multiple ways to run cron with docker. I think most common way is to setup another separate “cron” container using same image volume mounts, config and env variables as “app” with different entrypoint :

    image: nextcloud:${NEXTCLOUD_VERSION}
    container_name: dev-nextcloud-cron
    restart: unless-stopped
      - ./nextcloud.env
      - ./db.env
      - ./app:/var/www/html
      - ./files:/var/www/html/data
      - ./config:/var/www/html/config
    entrypoint: /
      - dev-nextcloud-app