default docker instalation problems with premisions

Hello,

new to nextcloud docker. I used a dietpi nextcloud before. After installing multipletimes and going in circles i decided for a default docker installation from the nexcloud github. I choosed the insecure, postgress fpm. no dockfile

i changed the minimun things and it was running till log in. then log in started to loop.

it is a problem with permissions. i try to change the ownership of the containers but didnt work. now i can not even access the webservice. because nginx says forbidden.

i have bin running in circles with this for days. installing and reinstalling diferent dockers or trzing to fix this issue with the premisions

i am mounting a external hd as default data directory. it is ext4. using raspian lite 64, raspberrypi 4 4gb

i guess its a commom problem or a very stupid thing i am not able to see, but i can not find a solution.

running
docker exec -u 33 -it next_app_1 php /var/www/html/occ files:scan --all

gives me now
{“reqId”:“Yo2P1GrbHpyqXvsjVmAE”,“level”:3,“time”:“2025-05-04T23:30:01+00:00”,“remoteAddr”:“”,“user”:false,“app”:“PHP”,“method”:“”,“url”:“–”,“message”:“fopen(/var/www/html/data/data_dir_writability_test_6817f8792ba2a.tmp): Failed to open stream: Permission denied at /var/www/html/lib/private/legacy/OC_Util.php#446”,“userAgent”:“–”,“version”:“31.0.4.1”,“data”:{“app”:“PHP”}}
Your data directory is invalid.
Ensure there is a file called “.ncdata” in the root of the data directory. It should have the content: “# Nextcloud data directory”

Your data directory is not writable.
Permissions can usually be fixed by giving the web server write access to the root directory. See Introduction — Nextcloud latest Administration Manual latest documentation.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/html/lib/private/Console/Application.php:143
Stack trace:
#0 /var/www/html/console.php(81): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/html/occ(33): require_once(‘/var/www/html/c…’)
#2 {main}{“reqId”:“Yo2P1GrbHpyqXvsjVmAE”,“level”:3,“time”:“2025-05-04T23:30:01+00:00”,“remoteAddr”:“”,“user”:false,“app”:“PHP”,“method”:“”,“url”:“–”,“message”:“fopen(/var/www/html/data/nextcloud.log): Failed to open stream: Permission denied at /var/www/html/lib/private/Log/File.php#53”,“userAgent”:“–”,“version”:“31.0.4.1”,“data”:{“app”:“PHP”}}

i would really apreciate a hint in the good direction.

I think it originated with www;data being 82:82 instead of 33:33.

Hello @pedante, welcome to the Nextcloud community! :handshake:

default webserver user in Docker community image is 33:33… (like all/most debian-like distros for www-data:www-data) it doesn’t matter which ID this user has in your host system or even if the user exists…

I don’t get what you trying to achieve? do you already have data there? if yes I would recommend you start with fresh local installation and customize step by step to the desired state. post you exact command lines, compose files and ls -al of the mounted directories to show issue…

also look at more advanced guide Nextcloud docker compose setup with Caddy (2024) also showing how to run the container with a custom non-root user

Please follow the directions for Accessing the Nextcloud command-line interface (occ), taking note of the instructions for the Alpine images.

i changed the minimun things and it was running till log in. then log in started to loop.

If still stuck, please post those “things” - i.e. your actual Compose file.