我正在运行以下php脚本。它创建一个脚本文件,该文件运行几个docker命令。但是由于某种原因,该脚本文件未运行docker命令。它确实运行普通的脚本文件命令,例如ls,pwd,echoetc。
$code = $_POST['source'];
$myfile = fopen("abc.py", "w");
fwrite($myfile, $code);
$myfile_new = fopen("execu_ta.sh", "w");
$txt = "#!/bin/bash\n\n";
fwrite($myfile_new, $txt);
$txt1 = "docker build -t python-new-world .";
$txt2 = "docker run python-new-world\n";
fwrite($myfile_new, $txt1);
fwrite($myfile_new, $txt2);
$result=shell_exec('path of the "execu_ta.sh" file');
echo $result;
?>
这里可能出什么问题了?
最佳答案
您需要设置可执行位chmod("your script filename", 0755);
或使用shell_exec('/bin/bash your_script')
关于php - 无法执行包含来自php文件的docker命令的bash脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53019578/