I love a reset mail when mail works. On a home server it often doesn’t, and the admin password is the one that gets forgotten.
Run the command with the user ID and type the new password at the prompts:
docker exec -it --user www-data nextcloud php occ user:resetpassword layla
The -it matters here, since occ has to ask you something. If you don’t know the exact user ID, occ user:list shows them. It can differ from the display name.
For a script there is an environment variable route. The variable has to exist inside the container, so pass it through with -e:
read -rs OC_PASS; export OC_PASS
docker exec -e OC_PASS --user www-data nextcloud php occ user:resetpassword --password-from-env layla
unset OC_PASS
Using read -s keeps the password out of your shell history and off the screen.
Think before you do this for someone who uses server side encryption with their own login password as key. Changing a password from outside can leave their encrypted files unreadable unless a recovery key was set up, so check the encryption section of the manual first.
Afterwards, ask the user to change it to something only they know, and to sign in again on their devices where needed.
Further reading: Nextcloud occ user commands
Going deeper: Guide: link Prowlarr to Sonarr and Radarr once, and stop typing indexers into every app