php - 无法执行包含来自php文件的docker命令的bash脚本

标签 php shell docker

我正在运行以下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/

相关文章:

docker - 如何更新 docker 容器内的软件?

postgresql - 将 docker 服务连接到 docker 数据库容器时出现 Postgres ENOTFOUND 错误

php - 函数内所有查询的 Codeigniter 事务

php - 使用 PHP 创建 LDAP 服务器

shell - 是否可以使用来自 shell 脚本的 teamcity 消息?

linux - 如何让 GNU-Screen 为所有用户共享 1 个 screen ?

docker - 如何在 docker 机器内外使用 IdentityServer4?

PHP编码规范

php - cron 作业不会写入文件

python - 如何作为命令的结果从另一个程序执行代码