使用ls、pwd甚至打开外部应用程序这样的简单命令,我使用子进程都可以成功,但在内置的电子应用程序中使用带有docker命令的exec时,我会收到以下错误:
exec Error: Command failed: docker exec -it 6bec55e9e86e touch home.html
the input device is not a TTY代码如下:
var exec = require('child_process').exec;
exec('docker exec -it 6bec55e9e86e touch casa.html', function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});发布于 2016-11-23 16:04:03
请删除-t标志。所以你的命令应该是docker exec -i 6bec55e9e86e touch casa.html。
这个错误the input device is not a TTY意味着你的输入设备不是电传类型(终端),并且在docker的命令中,-t标志符号是terminal,所以它们是冲突的。所以把它去掉就行了。
发布于 2016-08-11 12:57:18
使用spawn并将options.stdio设置为inherit将起作用:
const spawn = require('child_process').spawn;
spawn('docker', ['exec', '-it', '6bec55e9e86e', 'touch', 'casa.html'], { stdio: 'inherit' })https://stackoverflow.com/questions/38768704
复制相似问题