HowTo execute OCC commands in a nextcloud docker container


Last modified: 23.02.2021
estimated reading time < 1 min
Nextcloud can be maintained through the command line using the OCC command in the root folder of nextcloud

To execute those commands in a running docker container use the follwoing command to open an interactive shell in the container

It is assumed that nextcloud is running in a container named “nextcloud” in case that’s not true use the command
docker ps -a
to list all running containers and use the container-id instead of the name
docker exec -t -i nextcloud /bin/sh

Now change into the directory in which nextcloud is installed

If you are using the LinuxServer/Nextcloud Container the directory is as shown below
cd /config/www/nextcloud

Now execute the following command to get a list of available options

sudo -u abc php occ

Now you can execute any of the shown commands – here are some often used examples:

sudo -u abc php occ files:scan --verbose --path="/lars/files/Photos"
sudo -u abc php occ maps:scan-photos
sudo -u abc php occ preview:generate_all
Was this article helpful?
Dislike 0
Views: 1016