How to run a command as www-data in Docker image

The cause of the issue may be that the www-data user has no shell configured :
/bin/false (or some other variant) in /etc/passwd
The su command, called with the - opt, tries to open a shell, but it get denied by the system.
hence the error message.

solution, If you really have no choice :

  • Change temporarily the shell of the www-data user to be able to use it with su
    (Use chsh or edit /etc/passwd directly. )

As said before me, best use case for occ is to use it with sudo command

su - www-data -c ‘occ app:list’

This is the good one BTW

Regards