This article explains how to run OCC (OwnCloud Console) commands in a Nextcloud All-In-One (AIO) Docker container. OCC is a command-line tool for managing Nextcloud configurations, maintenance, and repairs. It is intended for intermediate to advanced Linux users with sudo or root access to a virtual or dedicated server.
Prerequisites
- Linux command line knowledge.
- sudo or root SSH access to the Docker host.
- Nextcloud AIO installed and running.
- Identify the Nextcloud container using
docker ps(typically namednextcloud-aio-nextcloud).
Steps to Run OCC Commands
Method 1: Enter the Container Interactively
- SSH into your Docker host.
- Identify the container name:
Look for the container nameddocker psnextcloud-aio-nextcloud. - Enter the container as root:
docker exec -it --user root nextcloud-aio-nextcloud bash - Navigate to the Nextcloud directory:
cd /var/www/html - Run the OCC command (e.g., for maintenance repair):
php occ maintenance:repair --include-expensive - Exit the container:
exit
Method 2: Run OCC Directly from the Host
- Execute the command in one line:
Replace the command as needed.docker exec -it --user root nextcloud-aio-nextcloud php /var/www/html/occ maintenance:repair --include-expensive
Alternative: Run as www-data User
If permissions issues arise, use the www-data user instead:
- Enter the container:
docker exec -it nextcloud-aio-nextcloud bash - Switch to www-data:
su - www-data -s /bin/bash - Navigate and run:
cd /var/www/html php occ maintenance:repair --include-expensive
Troubleshooting
- Permission Denied: Use
--user rootor switch to www-data. - Command Not Found: Confirm the path
/var/www/html/occ. - Always back up data before running maintenance commands.