💾 Archived View for wilw.capsule.town › log › 2022-01-28-nextcloud-docker-control.gmi captured on 2023-09-08 at 15:56:34. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-04-19)
-=-=-=-=-=-=-
If you've ever run your own Nextcloud [1] before, you may have noticed screens like the following in your instance's settings pages.
The messages advise a number of maintenance procedures to help ensure the smooth running of your instance. These could be to run database migrations or to update schemas in response to installing new apps.
Often these steps might involve running `occ` commands. `occ` [2] is Nextcloud's command-line interface, and is so-called because of its origins in ownCloud.
If you deploy your Nextcloud using Docker, then it isn't immediately obvious how to begin invoking the `occ` command.
Luckily, Docker makes this straight forward if you run Nextcloud in a container.
Assuming you manage your Docker orchestration using Docker Compose [3], if you wanted to run the `occ db:add-missing-indices` command from the screenshot above on a Nextcloud Docker container, you could run the following from your project's directory:
$ docker-compose exec --user www-data nextcloud php occ db:add-missing-indices
Where `nextcloud` is the service's name in your `docker-compose.yml` file
If you don't use Docker Compose, the same can be achieved using `docker exec` directly:
$ docker exec --user www-data 0e4c3hd9s049 php occ db:add-missing-indices
Where `0e4c3hd9s049` is the ID for your Nextcloud container, which you can find by running `docker ps` first.
In both cases, the command is structured the same. You may wish to note the `--user` flag. In my case, I tell Docker to run the command as `www-data` as that is the user that owns the Nextcloud `config/config.php` file in my setup. If you use a different user, then update this value in your command.
You may also need to run the `docker-compose` and `docker` commands as a superuser, depending on whether your normal user is in the appropriate group.