Run occ in nextcloud

I’ve installed nextcloud in my truenas scale. I’m having trouble to launch occ in the truenas shell. i.e.

$ sudo -u www-data php occ files:scan --all userid

I got this error:
sudo: php: command not found

Please advise,

Launch the console for nextcloud instance and use bash. /bin/bash

I’m new to truenas. How do I find my nextcloud instance. I can ssh to the truenas server.

now I know…nextcloud is running in docker. I tried to run the same command in the bash console. sudo -u www-data php occ files:scan --all userid It said can’t find sudo command. What’s wrong?

You’ll need to install sudo.

In the nextcloud app’s console, enter:

apt update && apt install -y sudo nano

(you may as well install nano while you’re there).

apt command requires privileged user (i.e. sudo) to run. I tried the admin user. It said account not exist. I don’t even know the root password for the truenas server. The only account exists (afa I know) is admin. It’s a catch 22 situation. Any suggestion to break this cycle? BTW, Copy/paste on the shell is disabled. Can I enable this operation?

The error message isn’t that sudo isn’t found, sudo is complaining that the command php isn’t.

Btw, if sudo isn’t available in the nextcloud container, you can try su.

the command su means to elevate the shell to root privilege. I don’t know the root password for the shell in nextcloud. Do you know?

That’s a fair point.

Since you’re running the container with docker how about using docker exec like this:
docker exec -u <user> -it <container> bash

That would give you shell access as the chosen user and you should be able to run the occ command without su or sudo.

I guess I really don’t understand the nextcloud run in truenas. I ran the command as you’ve suggested “docker exec -u admin -it nextcloud bash”, it gave me this error: zsh: command not found: docker.


What the apps tells me the nextcloud is a docker instance. Why would it says docker command not foud? It’s making no sense!!

Ok, that changes things. Docker commands do not work with the current apps system in 24.04.x, which is built on Kubernetes.

When you said docker I presumed you were either running it as a jail or in the 24.10-beta, which will change from Kubernetes to Docker, my mistake.

Kubernetes is more complicated but here’s a summary from another user who also had issues running commands in the nextcloud container in TrueNAS.

You run those in the TrueNAS shell and will likely need to prefix your commands with sudo. Obviously modify the last part of the command (with the php-bit) to do what you want to happen in the container.

You would be right. Kubernetes is way beyond my need for a home server. I have a working server on Rocky Linux running KVM. Functionally it’s working just fine. It has a typical HW RAID controller for the storage. It’s not optimum. I’d like my nextcloud server leverage ZFS to improve on the disk performance. I thought to have my existing home server migrate to TrueNAS to take full advantage of the ZFS.
Perhaps I should install Nextcloud as a VM instead of the nextcloud app. I’m have more experience with nextcloud in KVM. Would it still work well in TrueNAS with ZFS performance?

I can’t say how much work it will be to get nextcloud running in a VM. You have more control, certainly, but you also need to do more manually to get things running. It’s also less resource efficient since you need to preallocate CPU, RAM and storage.

If there’s any comfort, it’s that docker will become the apps subsystem in the next version of TrueNAS, 24.10. Planned release next month. Maybe that will be easier for you to maintain?
Read more about the next update here:

Thank you for your advice. I need disk performance as my existing server is suffering bottleneck on disk I/O. I don’t have too much issue with memory and CPU limitation. I’m running altogether maybe 4/5 VMs on my existing server. As long as I can gain disk I/O performance with TrueNAS I’m willing to give it a try.

1 Like