Hi;
It is more a curiosity than an issue but I was wondering how you and you and maybe you too run command as www-data inside the Docker image ?
Right now, when it require I install sudo than
such as an example :
sudo - www-data occ app:list
but I see the command su
so I would like to know if I’m just doing something wrong because any variation such as
su - www-data occ app:list
su www-data occ app:list
su - www-data -c ‘occ app:list’
su www-data -c “occ app:list”
simply repeat over and over :
This account is currently not available.
So if someones want to enlighten me
su
and sudo
are difference commands, and so will behave differently. Try running man su
and man sudo
and comparing the difference.
Correct syntax is sudo -u www-data php occ command
There is also an app (non official) that is a web occ console.
Hope this help
The cause of the issue may be that the www-data user has no shell configured :
/bin/false
(or some other variant) in /etc/passwd
The su
command, called with the -
opt, tries to open a shell, but it get denied by the system.
hence the error message.
solution, If you really have no choice :
Change temporarily the shell of the www-data user to be able to use it with su
(Use chsh
or edit /etc/passwd
directly. )
As said before me, best use case for occ
is to use it with sudo
command
su - www-data -c ‘occ app:list’
This is the good one BTW
Regards
from the hosts cli.
docker exec --user www-data <nextcloud-container-name> php occ <your-command>
no need to login the container.
8 Likes
I agree with @Reiner_Nippes , no need to log into the container
swehack
September 11, 2021, 11:13pm
7
I ran into this issue in kubernetes after an upgrade and this topic came up on Google so I just want to add my solution.
When you open a shell in the kubernetes container you must use su -p like this;
chsh -s /bin/bash www-data
su -p www-data -c 'php occ'
I’m way late to the game here, but I find this alias very helpful:
alias occ="docker exec --user www-data $(docker ps | grep nextcloud_nextcloud | awk '{print $11}') php occ"
I added this to my ~/.bash_aliases
and now I don’t have to google how to do it every time I need to use the cli.
You can execute occ
commands like this:
$ occ -V
Nextcloud 28.0.1
$ occ status
- installed: true
- version: 28.0.1.1
- versionstring: 28.0.1
- edition:
- maintenance: false
- needsDbUpgrade: false
- productname: Nextcloud
- extendedSupport: false
Hope this helps someone else too
1 Like