docker - tutorial - npm grunt
¿Cómo solucionar "el dispositivo de entrada no es un TTY" cuando se usa grunt-shell para invocar un script que llama a la ventana acoplable? (2)
Elimine la -t del comando de ejecución de la ventana acoplable:
docker run $RUN_ENV_FILE -i --rm --user node -v "$PWD":/app -w /app yaktor/node:0.39.0 $@
La -t le dice a la ventana acoplable que configure la tty, que no funcionará si no tiene una tty y trata de adjuntarla al contenedor (por defecto cuando no hace una -d ).
Al emitir grunt shell:test , recibo una advertencia "el dispositivo de entrada no es un TTY" y no quiero tener que usar -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.
Aquí está el comando Gruntfile.js :
shell: {
test: {
command: ''./run.sh npm test''
}
Aquí está 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 $@
Aquí están los scripts package.json relevantes con la test comando:
"scripts": {
"test": "mocha --color=true -R spec test/*.test.js && npm run lint"
}
¿Cómo puedo obtener un grunt para hacer feliz a docker con un TTY? ./run.sh npm test fuera de grunt funciona bien:
$ ./run.sh npm test
> [email protected] test /app
> mocha --color=true -R spec test/*.test.js && npm run lint
[snip]
105 passing (3s)
> [email protected] lint /app
> standard --verbose
Esto solucionó un problema molesto para mí. El guión tenía estas líneas:
docker exec **-it** $( docker ps | grep mysql | cut -d'' '' -f1) mysql --user= ..... > /var/tmp/temp.file
mutt -s "File is here" [email protected] < /var/tmp/temp.file
La secuencia de comandos se ejecutaría muy bien si se ejecutara directamente y el correo llegaría con el resultado correcto. Sin embargo, cuando se ejecuta desde cron , ( crontab -e ) el correo vendría sin contenido. Probé muchas cosas en torno a permisos, conchas y caminos, etc. Sin embargo, ¡no hay alegría!
Finalmente encontré esto:
*/20 * * * * scriptblah.sh > $HOME/cron.log 2>&1
Y en ese archivo cron.log encontramos esta salida:
el dispositivo de entrada no es un TTY
La búsqueda me llevó aquí. Y después de que quité la -t , ¡está funcionando muy bien ahora!
docker exec **-i** $( docker ps | grep mysql | cut -d'' '' -f1) mysql --user= ..... > /var/tmp/temp.file