Simon, I'm sorry to bother you - another weirdness which is (most chances) just my miss: under docker the traversing script is called two times for some reason. Here are the details:
$ docker run --rm --name zap-live2 -v $(pwd):/zap/wrk:rw -t owasp/zap2docker-live bash -c "zap.sh -autorun wrk/auto-test2.yaml -cmd; cat wrk/auto-test2.yaml; cat wrk/test.js"
Found Java version 11.0.16
Available memory: 3426 MB
Using JVM args: -Xmx856m
1702 [main] INFO  org.parosproxy.paros.Constant - Copying default configuration to /home/zap/.ZAP_D/config.xml
2072 [main] INFO  org.parosproxy.paros.Constant - Creating directory /home/zap/.ZAP_D/session
2074 [main] INFO  org.parosproxy.paros.Constant - Creating directory /home/zap/.ZAP_D/dirbuster
2074 [main] INFO  org.parosproxy.paros.Constant - Creating directory /home/zap/.ZAP_D/fuzzers
2075 [main] INFO  org.parosproxy.paros.Constant - Creating directory /home/zap/.ZAP_D/plugin
Sep 09, 2022 8:44:44 AM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
Job script set action = add
Job script set type = active
Job script set engine = ECMAScript : Oracle Nashorn
Job script set name = test.js
Job script set file = wrk/test.js
Job test set action = run
Job test set type = standalone
Job test set engine =
Job test set name = test.js
Job script started
Job: script Start action: add
Job script finished
Job script started
Job: test Start action: run
test
test
Job script finished
Automation plan succeeded!
---
env:
  contexts:
  - name: "test"
    urls:
    - "
example.com"
    includePaths:
    excludePaths: []
  parameters:
    failOnError: true
    failOnWarning: false
    progressToStdout: true
  vars: {}
jobs:
- parameters:
    action: "add"
    type: "active"
    engine: "ECMAScript : Oracle Nashorn"
    name: "test.js"
    file: "wrk/test.js"
  name: "script"
  type: "script"
- parameters:
    action: "run"
    type: "standalone"
    engine: ""
    name: "test.js"
  name: "test"
  type: "script"
print("test");