0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

the input device is not a TTYの解決方法

0
Posted at

概要

GithubActonsでdockerコマンドを使用してバッチ作成する必要があったので実行したがエラーが出て動かなかった
色々調べた結果、何気なく実行していたオプションが問題だった

実行内容

docker exec -it test-php /bin/bash -c 'ls -la'

エラー内容

 Container test-php-1  Started
 Container test-web-1  Starting
 Container test-web-1  Started
the input device is not a TTY
Error: Process completed with exit code 1.

解決方法

docker exec -i test-php /bin/bash -c 'ls -la'
  • それぞれのオプションの役割

i(--interactive)

コンテナの標準入力(stdin)を開いたままにする
入力を受け付けるために必要
例えば、bashpythonなどのREPL(対話型)に必須

t(--tty)
コンテナに擬似端末(TTY)を割り当てる
色付き出力やコマンドラインの制御文字が有効になる
lesstophtop などのツールやシェルのプロンプト表示などで使われる

ttyはフォアグラウンドでコマンド実行するために必要ですが、
CI/CDのため、それが必要ないのでサポートされておらず、エラーが出力されて失敗してました。
-cで入力したコマンドの結果のみ知りたいだけなので、-iのみ指定します。
指定した結果、問題なく実行できました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?