如何解决方案“输入设备不是TTY”当使用grunt-shell调用一个调用docker运行的脚本时? [英] How to workaround "the input device is not a TTY" when using grunt-shell to invoke a script that calls docker run?

查看:711
本文介绍了如何解决方案“输入设备不是TTY”当使用grunt-shell调用一个调用docker运行的脚本时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当发行 grunt shell:test 时,我收到警告输入设备不是TTY&不想使用 -f

When issuing grunt shell:test, I'm getting warning "the input device is not a TTY" & don't want to have to use -f:

$ grunt shell:test
Running "shell:test" (shell) task
the input device is not a TTY
Warning: Command failed: /bin/sh -c ./run.sh npm test
the input device is not a TTY
 Use --force to continue.

Aborted due to warnings.

这里是 Gruntfile.js 命令: / p>

Here's the Gruntfile.js command:

shell: {
  test: {
    command: './run.sh npm test'
  }

这是 run.sh

#!/bin/sh
# should use the latest available image to validate, but not LATEST
if [ -f .env ]; then
  RUN_ENV_FILE='--env-file .env'
fi
docker run $RUN_ENV_FILE -it --rm --user node -v "$PWD":/app -w /app yaktor/node:0.39.0 $@

这是相关的包。 json 脚本与命令测试

"scripts": {
  "test": "mocha --color=true -R spec test/*.test.js && npm run lint"
}

如何获得 grunt 使 docker 对TTY感到满意?执行 ./ run.sh npm test grunt以外的工作正常:

How can I get grunt to make docker happy with a TTY? Executing ./run.sh npm test outside of grunt works fine:

$ ./run.sh npm test

> yaktor@0.59.2-pre.0 test /app
> mocha --color=true -R spec test/*.test.js && npm run lint


[snip]

  105 passing (3s)


> yaktor@0.59.2-pre.0 lint /app
> standard --verbose


推荐答案

从码头运行命令:

docker run $RUN_ENV_FILE -i --rm --user node -v "$PWD":/app -w /app yaktor/node:0.39.0 $@

-t告诉docker配置tty,如果没有tty并尝试附加到容器(如果不执行-d),则不起作用。

The "-t" tells docker to configure the tty, which won't work if you don't have a tty and try to attach to the container (default when you don't do a "-d").

这篇关于如何解决方案“输入设备不是TTY”当使用grunt-shell调用一个调用docker运行的脚本时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆