docker-library / owncloud

Docker Official Image packaging for ownCloud
101 stars 77 forks source link

Could not execute the `php occ` inside the container #67

Closed armandabric closed 8 years ago

armandabric commented 8 years ago

To easyly update a config value I want to use the occ CLI (see https://doc.owncloud.org/server/9.0/admin_manual/configuration_server/occ_command.html#setting-an-array-configuration-value) but as the image do not provide sudo it's impossible.

From inside the container:

$ php occ
Console has to be executed with the user that owns the file config/config.php
Current user: root
Owner of config.php: www-data
Try adding 'sudo -u www-data ' to the beginning of the command (without the single quotes)

$ sudo
/bin/sh: 3: sudo: not found

Own could I use the occ CLI with owncloud in a container?

pierreozoux commented 8 years ago

easy :)

docker exec -it -user www-data my_container bash
armandabric commented 8 years ago

It's works! :tada: Thanks for the help.

martingabelmann commented 8 years ago

or - in your own build - create a script /usr/bin/occ (or somewhere else within the PATH) with the following content:

#!/bin/bash
su www-data -s /bin/bash -c "php /var/www/html/occ $@"

then you can for instance simply run

docker exec oc_container occ upgrade

(or even set a alias occ='docker exec oc_container occ')

lazyfrosch commented 8 years ago

@martingabelmann could you add this via an PR as /usr/local/sbin/occ ?

boldt commented 6 years ago

Just for documentation: For me docker exec -u www-data -it nextcloud /bin/bash worked.