-
-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Problem
When executing a command inside a docker container, it is possible to specify a user. Some tasks require running with a specific user, e.g. the nextcloud fulltext search re-index job. For example:
docker exec -u www-data nextcloud php occ fulltextsearch:indexWhen I'm trying to add this job to docker-crontab like this to run it every night at 1:30h:
- name: nextcloud-fulltext
command: php occ fulltextsearch:index
comment: re-indexing nextcloud fulltext search for documents
container: nextcloud
schedule: '30 1 * * *'I get an error from the nextcloud container that I have to run the command as user www-data.
Proposed solution
It would be great to be able to specify a user in config.yml which will be translated into a docker run -u user command in the generated *.sh file for the cronjob. I think this would solve this issue.
Workaround
Right now I'm doing a workaround by scheduling a docker command running within the docker-crontab container which then executes a command within the nextcloud container.
- name: nextcloud-fulltext
command: docker exec -u www-data nextcloud php occ fulltextsearch:index
comment: re-indexing nextcloud fulltext search for documents
container: crontab
schedule: '30 1 * * *'This generates a docker exec command which then runs again a docker exec command but with specified user.