Nextcloud docker cron help

There’s something I’m missing about getting cron running in my docker nextcloud instance. Any help would be greatly appreciated. The nextcloud docs instructions for checking on the cron service only work on a full linux installation. All the containers are running in docker. Thanks

v21.0.1
Admin basic settings is set to cron

services:
  nextcloud:
    image: nextcloud:apache
    container_name: nextcloud
    restart: unless-stopped
    networks:
      - t2_proxy
    depends_on:
      - db
    volumes:
      - nextcloud_data:/var/www/html/data
      - nextcloud_config:/var/www/html/config
      - nextcloud_html:/var/www/html
      - nextcloud_custom_apps:/var/www/html/custom_apps
      - nextcloud_themes:/var/www/html/themes
    secrets:
      - nextcloud_mysql_database
      - nextcloud_mysql_password
      - nextcloud_mysql_user
    environment:
      - MYSQL_HOST=db
      - MYSQL_DATABASE_FILE=/run/secrets/nextcloud_mysql_database
      - MYSQL_USER_FILE=/run/secrets/nextcloud_mysql_user
      - MYSQL_PASSWORD_FILE=/run/secrets/nextcloud_mysql_password
    labels:
      - "traefik.enable=true"
      ## HTTP Routers
      - "traefik.http.routers.nextcloud-rtr.entrypoints=https"
      - "traefik.http.routers.nextcloud-rtr.rule=Host(`cloud.$DOMAINNAME`)" 
      ## Middlewares
      - "traefik.http.routers.nextcloud-rtr.middlewares=chain-no-auth@file" 
      ## HTTP Services
      - "traefik.http.routers.nextcloud-rtr.service=nextcloud-svc"
      - "traefik.http.services.nextcloud-svc.loadbalancer.server.port=80"

  cron_nc:
    container_name: cron_nc
    image: nextcloud:apache
    restart: unless-stopped
    volumes:
      - nextcloud_data:/var/www/html/data
      - nextcloud_config:/var/www/html/config
      - nextcloud_html:/var/www/html
      - nextcloud_custom_apps:/var/www/html/custom_apps
      - nextcloud_themes:/var/www/html/themes
    entrypoint: /cron.sh
    depends_on:
      - db

  db:
    image: mariadb
    container_name: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: unless-stopped
    networks:
      - t2_proxy
    volumes:
      - mariadb:/var/lib/mysql
    secrets:
      - nextcloud_mysql_database
      - nextcloud_mysql_password
      - nextcloud_mysql_user
      - mariadb_root_password
    environment:
      - MYSQL_DATABASE_FILE=/run/secrets/nextcloud_mysql_database
      - MYSQL_USER_FILE=/run/secrets/nextcloud_mysql_user
      - MYSQL_PASSWORD_FILE=/run/secrets/nextcloud_mysql_password
      - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mariadb_root_password

I’ve found that it’s more trouble than it’s worth to try to set up cron as a separate container. Building one with cron using their Dockerfile isn’t hard, but honestly the simplest solution is to call the container’s cron.php from the host’s cron instead. Just prefix it with the necessary Docker exec command to execute the command in the container.

3 Likes

Hm. Thanks for the tip. I’m honestly not sure it’s broken. The nextcloud admin interface doesn’t think it’s running, but looking at the cron container logs, it looks like it’s doing something.