If you’re using the official docker image you shouldn’t enter the image as a user. Just use the following:
docker exec -ti <container_name> entrypoint bash
entrypoint
will load the environment into your current shell.
Afterwards you can just run occ
which will call the wrapper script and run as www-data
using sudo
. You can have a look at the wrapper script the following way:
cat $(command -v occ)