Skip to content

Execute scripts from docker container #417

Open

Description

@Mailblocker

Hi everyone,
I am running NextCloud within docker (based on “with-nginx-proxy/mariadb/fpm”) which works very well. But I can not get Flow working with external scripts.

I want to run a script when a defined file is opened. I have installed the “external script” app and configured a flow with:
“File accessed” and file name is “nextcloud_flow_test.txt” run script at “/var/www/html/config/test.sh”.

But the script is not executed when accessing the file from my NextCloud Webinterface.

The script itself is accessable from the docker container. I started it via an interactive shell from the container (docker exec -it nextcloud bash). Currently the script just inserts the current date to a text file (date >> test.txt) which works fine when executed manually.

Is there anything I am missing?

Activity

  1. blizzz commented on Oct 6, 2025

    @blizzz
    Member

    Not running on docker, and not having an idea why it should not work in principle about of the usual (user, permissions).

    A script is executed from a background job (make they are executed). Set the loglevel to 1 and watch the audit.log (also in data dir), to first verify whether the flow is actually activated and executed.

  2. Mailblocker commented on Oct 7, 2025

    @Mailblocker
    Author

    I checked the logs and can find entries of workflow_script:

    Info workflow_script executing sh -c '/var/www/html/config/test.sh' >/dev/null &

    with the follwoing details:

    {"reqId":"WaQmOM0mhJTg921r8qGr","level":1,"time":"2025-10-07T18:29:05+00:00","remoteAddr":"","user":"--","app":"workflow_script","method":"","url":"--","message":"executing sh -c '/var/www/html/config/test.sh' >/dev/null &","userAgent":"--","version":"31.0.9.1","data":{"app":"workflow_script"},"id":"68e55d1eb268e"}

    In the web view my nextcloud instances states cron is being used and the last job ran seconds ago.

    I changed the script to write execute date >> /test.txt in case the script is executed in some sub directory and the resulting file is stored anywhere. But still I can not find the file test.txt. Either within the docker container of the nextcloud application, the docker container of the cron job or also on the host machine.

  3. Mailblocker commented on Oct 17, 2025

    @Mailblocker
    Author

    Is there anything else I can try?

  4. executed commented on Oct 20, 2025

    @executed

    @Mailblocker
    'date >> /test.txt' means it's gonna go into very root of filesystem - probably don't have rights there.
    Try this sample script:
    touch /var/www/html/data/TEST.txt chmod 777 /var/www/html/data/TEST.txt chown www-data:www-data /var/www/html/data/TEST.txt echo "HELLO WORLD" > /var/www/html/data/TEST.txt
    Then verify using this command:
    cat /var/www/html/data/TEST.txt
    Should output HELLO WORLD obviously.

  5. Mailblocker commented on Oct 21, 2025

    @Mailblocker
    Author

    @Mailblocker 'date >> /test.txt' means it's gonna go into very root of filesystem - probably don't have rights there. Try this sample script: touch /var/www/html/data/TEST.txt chmod 777 /var/www/html/data/TEST.txt chown www-data:www-data /var/www/html/data/TEST.txt echo "HELLO WORLD" > /var/www/html/data/TEST.txt Then verify using this command: cat /var/www/html/data/TEST.txt Should output HELLO WORLD obviously.

    Thanks for the input! Unfortunately no change of result.

    I created the script as you mentioned and I got this file now in my docker container available:
    -rwxrwxrwx 1 www-data www-data 37 Oct 21 19:15 TEST.txt

    It is accessable as expected but I needed to change its contents to get an actual timestamp when the script was executed the last time:
    echo "date >> /var/www/html/data/test2.txt" > /var/www/html/data/TEST.txt

    It worked to execute this script from the container shell itself. But in this case the file test2.txt is created with root ownership. So I deleted it and tried to execute the script via flow with the same result as mentioned my initial post:
    The nextcloud log states a script has been executed. But no file test2.txt is created within the docker volume.

  6. Mailblocker commented on Oct 30, 2025

    @Mailblocker
    Author

    Can anyone reproduce this error? I am a little bit stuck here, not sure where the problem is located. Is it me or is this a problem in the combination docker + workflow script?

  7. Pitastic commented on Jul 12, 2026

    @Pitastic

    I learned some details in my long debug Session.

    1. You may want to check if you are in the right container. I have a compose where CRON service has a separate container beside APP. The script have to be accessible in the CRON container (not APP).

    I missed that for hours...

    1. As you see in the Log /dev/null is used. If your script fails you won't see it in the logs. Better trigger your workflow and than php -f /your/path/cron.php with www-data user manually (in the right container). Add extra logging like seen below.

    2. If your script takes longer than cron.php it gets killed when the php process ends e.g. a curl (even though subshell is spawned with &. That ws the hardest lesson...

    SonI end up wuth a robust solution for point 2 and 3. In the run_script App I defined the command as follows:

    setsid /bin/bash /test.sh %f </dev/null >>/tmp/cron.log 2>&1 &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions