Run files:scan --all in a docker environment

Hi, I’m new to Nextcloud and linux, I want to move some files to the NC data directory and I’m trying to run a scan:files --all but I can’t get it to work.
My NC run under docker on a Qnap NAS, and this is the full path:


So I log to SSH with admin privileges and run:

php /share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/Nextcloud/_data/www/nextcloud/occ files:scan --all

But it gives me “php command not found” error…
Someone can help? Thanks

You have to enter the docker container to issue commands to it once you’ve logged in over SSH.

Something like docker exec -it nextcloud /bin/bash

In this case you can define the full path of php.
/var/www/where/is/php /share/CACHEDEV1_DATA/Container/container-station-data/lib/docker/volumes/Nextcloud/_data/www/nextcloud/occ files:scan --all

Ok, wonderful! And how can I find where php is located? It is part of nextcloud, of the docker or the main system?

you have to use php inside of your container… official docker image finds php without full path. I use to run commands inside of the container as following:

# list users
docker exec --user www-data <container name> php occ user:list

# list apps
docker exec --user www-data <container name> php occ app:list

fwiw, I’ve had to write full php path a number of times inside Nextcloud docker containers, so ymmv. Either way, will work with small experimentation.

Think of it as main system → Docker → Nextcloud
To access Nextcloud from the command line you have to

  1. enter the main system via SSH
  2. enter the Docker container
  3. Interact with Nextcloud

@wwe 's command combines these last two steps.

this or any command using www-data return error:

unable to find user www-data: no matching entries in passwd file

And I don’t know what’s the meaning…

Please use forum search or your favorite internet search engine…

1 Like

I did it! Thank you both @wwe and @just
This is my functioning command:

/share/CACHEDEV1_DATA/.qpkg/container-station/bin/docker exec --user abc nextcloud php /config/www/nextcloud/occ files:scan --all