=> 🏡 Home | Back to gemlog

Interacting with a Nextcloud instance deployed with Docker

Posted on 28 January 2022

If you've ever run your own Nextcloud [1] before, you may have noticed screens like the following in your instance's settings pages.

=> 1

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.

=> 2

If you deploy your Nextcloud using Docker, then it isn't immediately obvious how to begin invoking the occ command.

Invoking occ on a running Nextcloud Docker container

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:

=> 3

$ 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.

=> Reply via email | Back to gemlog

Proxy Information
Original URL
gemini://wilw.capsule.town/log/2022-01-28-nextcloud-docker-control.gmi
Status Code
Success (20)
Meta
text/gemini;lang=en-GB
Capsule Response Time
170.014256 milliseconds
Gemini-to-HTML Time
0.657399 milliseconds

This content has been proxied by September (ba2dc).