首页

php exec 执行docker命令报错: the input device is not a TTY

当后台脚本执行docker命令时或者使用php的exec函数执行docker命令时可能会报错,比如需要执行容器里的脚本: <code> #原本的命令 docker exec -it 你的容器id "ls -al" #php调用exec执行docker命令 exec('docker exec -it 容器id "ls -al"', $arr); var_dump($arr); #保存为index.php,访问网站路径执行后没有任何输入或者提示,于是改为 var_dump(shell_exec('docker exec -it 容器id "ls -al"')); #这次如果php权限不够会报 xxxx.sock: connect: permission denied #如果权限足够用了,加上sudo,像这样 var_dump(shell_exec('sudo docker exec -it 容器id "ls -al"', $arr));可能会报the input device is not a TTY, 因为docker检测到运行命令后没有控制台输出,只要去掉 -it 参数即可 var_dump(shell_exec('sudo docker exec 容器id "ls -al"')); </code>
更多>>
laravel5.5诡异的查询bug ubuntu20服务器下安装图形界面 编译安装ngrok时报go get ngrok/...: malformed module path "ngrok": missing dot in first path element 解决Vue烦人的数据双向绑定赋值问题 在deepin系统下基于ffplay用命令行播放音乐