Cron job cannot execute due to invalid data directory

I’m using a docker container for nextcloud, and when I view the system overview (from settings → overview) I see the following error:

It was not possible to execute the cron job via CLI. The following technical errors have appeared:
Your data directory is invalid Ensure there is a file called “.ocdata” in the root of the data directory.
Cannot create “data” directory This 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

My data directory should be fine, I have it mounted in docker-compose with

volumes:
- data:/var/www/html/data

the permissions should be fine as well

$ ls -ld /var/www/html/data/
drwxrwx--- 7 www-data root 4096 Jan 28 17:04 /var/www/html/data/

$ ls -lA /var/www/html/data/.ocdata
-rw-r--r-- 1 www-data www-data 0 Jan 28 17:04 /var/www/html/data/.ocdata

my datadirectory is configured for this folder as well

'datadirectory' => '/var/www/html/data',

What else do I need to check for this, or is this an invalid error?

I’d try:

‘datadirectory’ => ‘/data’,

Hi,

I did try changing that and mounted my data folder at both location:

volumes:
- data:/var/www/html/data
- data:/data

but I see the same error

try

‘datadirectory’ => ‘/data/nextcloud/data’,

I just tried that and see the same. Is there any reason changing the data directory would affect this since it’s just mounting the same folder in different locations? The application itself works, so I know that the data directory is fine for actual file operations, it’s just the cron job error that I see. I did also try creating a separate /data folder with .ocdata file and leaving the datadirectory pointed to the original /var/www/html/data but did not see any change.

I am seeing the same message on my Centos 7 machine (Nextcloud manually installed from tarball):

It was not possible to execute the cron job via CLI. The following technical errors have appeared:
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.

Both data directories /var/www/html/nextcloud/* and my external data location /media/user/ext_drive/nextcloud/* are owned by apache:apache. What can prevent the cron job?

All help is appriciated!

This issue was resolved for me by adding the ownership of the mounted drive root (/media/username/mounted_drive/) to apache:apache with a chown, and not only the nextcloud data folder (/media/username/mounted_drive/nextcloud/)

For the the problem was resolved by adding the data volume entry in the cron container as well