Nextcloud container won't function after restart

I’m able to get through the setup of Nextcloud and start using it. However, once I need to restart the docker container for any reason (historically an update) I’m no longer able to use Nextcloud. I’m greeted with a generic server error once everything spins back up.

I understand the error points to permissions issues, but here’s where I’m stuck. In my docker-compose.yml if I specify PUID/PGID as 1000 (the user I’m running docker as on the box) I first get a generic, text only, server error message. I have to chown -R www-data:www-data /path/to/nextcloud/ in order for the Nextcloud branded error to show, which has the request ID I use to find the error in the logs.

If I set PUID/PGID to 33 (www-data) the plain text error is the only thing I get and I can’t get the Nextcloud branded page with the request ID to show even if I muck with ownership. Also, nothing ends up hitting the error log at all.

The issue occurs on both the latest image as well as the php8 one.

Relevant entry in /log/nginx/error.log:

2022/01/13 16:46:47 [error] 409#409: *5 FastCGI sent in stderr: "PHP message: {"reqId":"67IYfrMQd2mElShdOQhi","level":3,"time":"2022-01-13T23:46:47+00:00","remoteAddr":"10.10.2.20","user":"--","app":"PHP","method":"GET","url":"/","message":"touch(): Utime failed: Permission denied at /config/www/nextcloud/lib/private/Config.php#248","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0","version":"","exception":{"Exception":"Error","Message":"touch(): Utime failed: Permission denied at /config/www/nextcloud/lib/private/Config.php#248","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/config/www/nextcloud/lib/private/Config.php","line":248,"function":"touch"},{"file":"/config/www/nextcloud/lib/private/Config.php","line":138,"function":"writeData","class":"OC\\Config","type":"->"},{"file":"/config/www/nextcloud/lib/private/SystemConfig.php","line":131,"function":"setValue","class":"OC\\Config","type":"->"},{"file":"/config/www/nextcloud/lib/private/legacy/OC_Util.php","line":1119,...PHP message: {"reqId":"67IYfrMQd2mElShdOQhi","level":3,"time":"2022-01-13T23:46:47+00:00","remoteAddr":"10.10.2.20","user":"--","app":"PHP","method":"GET","url":"/","message":"fopen(/config/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /config/www/nextcloud/lib/private/Config.php#249","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0","version":"","exception":{"Exception":"Error","Message":"fopen(/config/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /config/www/nextcloud/lib/private/Config.php#249","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/config/www/nextcloud/lib/private/Config.php","line":249,"function":"fopen"},{"file":"/config/www/nextcloud/lib/private/Config.php","line":138,"function":"writeData","class":"OC\\Config","type":"->"},{"file":"/config/www/nextcloud/lib/private/SystemConfig.php","
2022/01/13 16:46:47 [error] 409#409: *5 FastCGI sent in stderr: "PHP message: {"reqId":"67IYfrMQd2mElShdOQhi","level":3,"time":"2022-01-13T23:46:47+00:00","remoteAddr":"10.10.2.20","user":"--","app":"PHP","method":"GET","url":"/","message":"fopen(/config/www/nextcloud/data/nextcloud.log): Failed to open stream: No such file or directory at /config/www/nextcloud/lib/private/Log/File.php#84","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 Firefox/95.0","version":""}" while reading upstream, client: 10.10.2.20, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "cloud.ncflake"

My docker-compose.yml:

---
version: "2.1"
services:
  nextcloud:
    image: lscr.io/linuxserver/nextcloud:php8
    container_name: nextcloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Boise
    volumes:
      - /home/doc_brown/compose/nextcloud/config:/config
      - /mnt/unraid/nextcloud/data:/data
    ports:
      - 2443:443
    restart: unless-stopped
  db:
    image: lscr.io/linuxserver/mariadb
    container_name: nextcloud-mariadb
    volumes:
      - db:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=SWEETPW
      - MYSQL_PASSWORD=SEMISWEETPW
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud_db_user
      - TZ=America/Boise
    restart: unless-stopped
volumes:
  db:
  nextcloud: