Closed jiusi9 closed 1 month ago
The issue you're encountering with executing OS commands using Python's os
and subprocess
modules in Dify's self-hosted Docker environment is likely due to security restrictions. Dify employs several security measures to prevent unauthorized execution of OS commands:
Seccomp Whitelist Policy: This policy allows only specific system calls, which can prevent the execution of certain OS commands [1].
File System Isolation: The environment is isolated, limiting the ability to execute commands that could affect the host system [1].
Network Isolation: Separate network configurations further restrict unauthorized access [1].
These measures are in place to ensure a secure execution environment. If you need to execute specific commands, you might need to adjust the security settings or explore alternative approaches that comply with these restrictions.
To continue talking to Dosu, mention @dosu.
def main() -> dict:
import os
hostname = os.popen("hostname")
aaa = os.read(hostname)
return {
"result": hostname,
}
See dify-sandbox's faq.
Self Checks
Dify version
0.10.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
import os, subprocess package, but can not be executed. It always report "operation not permitted"
Can not allow to execute some OS command?
✔️ Expected Behavior
Hope to execute os command on sandbox containers.
❌ Actual Behavior
No response