状況
以下のようにdocker compose exec
を実行したところthe input device is not a TTY
となりました。
ターミナル
$ docker compose exec <サービス名> <コマンド>
the input device is not a TTY
解消法
docker compose exec
に-T
を付けることで解消しました。
ターミナル
$ docker compose exec -T <サービス名> <コマンド>
-T
オプションについて確認するためにdocker compose exec --help
を実行しました。
ターミナル
$ docker compose exec --help
Usage: docker compose exec [options] [-e KEY=VAL...] [--] SERVICE COMMAND [ARGS...]
Execute a command in a running container.
Options:
-d, --detach Detached mode: Run command in the background.
-e, --env stringArray Set environment variables
--index int index of the container if there are multiple instances of a service [default: 1].
(default 1)
-T, --no-TTY docker compose exec Disable pseudo-TTY allocation. By default docker compose exec allocates a TTY.
--privileged Give extended privileges to the process.
-u, --user string Run the command as this user.
-w, --workdir string Path to workdir directory for this command.
-T
を付けることによって擬似TTYの割り当てを無効にすることができるようです。