How to Interact with OCC in a Docker Container for Nextcloud Installs Print

  • occ, Nextcloud, cli, Docker
  • 0

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 named nextcloud-aio-nextcloud).

Steps to Run OCC Commands

Method 1: Enter the Container Interactively

  1. SSH into your Docker host.
  2. Identify the container name:
    docker ps
    Look for the container named nextcloud-aio-nextcloud.
  3. Enter the container as root:
    docker exec -it --user root nextcloud-aio-nextcloud bash
  4. Navigate to the Nextcloud directory:
    cd /var/www/html
  5. Run the OCC command (e.g., for maintenance repair):
    php occ maintenance:repair --include-expensive
  6. Exit the container:
    exit

Method 2: Run OCC Directly from the Host

  1. Execute the command in one line:
    docker exec -it --user root nextcloud-aio-nextcloud php /var/www/html/occ maintenance:repair --include-expensive
    Replace the command as needed.

Alternative: Run as www-data User

If permissions issues arise, use the www-data user instead:

  1. Enter the container:
    docker exec -it nextcloud-aio-nextcloud bash
  2. Switch to www-data:
    su - www-data -s /bin/bash
  3. Navigate and run:
    cd /var/www/html
    php occ maintenance:repair --include-expensive

Troubleshooting

  • Permission Denied: Use --user root or switch to www-data.
  • Command Not Found: Confirm the path /var/www/html/occ.
  • Always back up data before running maintenance commands.

Was this answer helpful?

« Back