Cron not working with dockerized nextcloud behind nginx-proxy

Hi there,

I just set up my nextcloud instance behind the nginx-proxy by jwilder
Everything looks quite good and nextcloud is running smoothly, however I can’t get cron running (I used the compose-examples found here)

I had a look at the cron-container logs and they’re showing this:

crond:  line php -f /var/www/html/cron.php
crond:  job: 0 php -f /var/www/html/cron.php
crond: child running /bin/ash
crond: USER www-data pid   8 cmd php -f /var/www/html/cron.php
PHP Warning:  fileperms(): stat failed for /var/www/html/data/nextcloud.log in /var/www/html/lib/private/Log/File.php on line 83
{"reqId":"D4efXZXgDpt2AQkS4SVp","level":3,"time":"2020-04-21T11:45:00+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fopen(/var/www/html/data/data_dir_writability_test_5e9edcbc55443.tmp): failed to open stream: Permission denied at /var/www/html/lib/private/legacy/util.php#797","userAgent":"--","version":"18.0.3.0"}
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.

Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/18/go.php?to=admin-dir_permissions.

PHP Warning:  fileperms(): stat failed for /var/www/html/data/nextcloud.log in /var/www/html/lib/private/Log/File.php on line 83
{"reqId":"D4efXZXgDpt2AQkS4SVp","level":3,"time":"2020-04-21T11:45:00+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fileperms(): stat failed for /var/www/html/data/nextcloud.log at /var/www/html/lib/private/Log/File.php#83","userAgent":"--","version":"18.0.3.0"}
{"reqId":"D4efXZXgDpt2AQkS4SVp","level":3,"time":"2020-04-21T11:45:00+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"chmod(): No such file or directory at /var/www/html/lib/private/Log/File.php#84","userAgent":"--","version":"18.0.3.0"}
crond: wakeup dt=10
crond: wakeup dt=50
crond: file www-data:

As the volume was created by docker itself and this looks like a file permission issue I don’t want to touch it manually.
Any ideas? I’m close to giving up on the cron thing :frowning:

Edit:
This is my compose file (my nginx-proxy is running seperately)

version: '3'

services:
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    env_file:
      - db.env

  redis:
    image: redis:alpine
    restart: always

  app:
    image: nextcloud:fpm-alpine
    restart: always
    volumes:
      - nextcloud:/var/www/html
      - /data/nextcloud:/var/www/html/data
    environment:
      - MYSQL_HOST=db
      - REDIS_HOST=redis
    env_file:
      - db.env
    depends_on:
      - db
      - redis

  web:
    build: ./web
    restart: always
    volumes:
      - nextcloud:/var/www/html:ro
    environment:
      - VIRTUAL_HOST=xxx
      - LETSENCRYPT_HOST=xxx
      - LETSENCRYPT_EMAIL=xxx
    depends_on:
      - app
    networks:
      - proxy
      - default

  cron:
    image: nextcloud:fpm-alpine
    restart: always
    volumes:
      - nextcloud:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis

volumes:
  db:
  nextcloud:

networks:
  proxy:
    external:
      name: https-proxy
  default:

Have you tried building cron support into the Nextcloud image itself? They have a Dockerfile and instructions here:

Hey,

I tried it with building the image given as example here https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/cron/fpm-alpine
But I still got the same error messages…

the cron container asks you that he also wants to access your data. :wink: