環境
現象
- GitBashやEmacs Shellなどの上で下記コマンドを実行する
docker-compose exec --user=laradock workspace bash
the input device is not a TTY
- ttyと標準入力をつないで
bash
で対話しようとしているので、これはまあわかる
docker container exec -it
の-it
に相当する部分
- しかし、ttyと標準入力をつなぐ必要のない操作でも怒られてしまう
docker-compose exec --user=laradock workspace vendor/bin/phpunit
the input device is not a TTY
回避方法
- そもそもとして、
docker-compose.yml
でworkspaceコンテナにはtty
フラグが指定されている
workspace:
build:
context: ./workspace
args:
- LARADOCK_PHP_VERSION=${PHP_VERSION}
...
ports:
- "${WORKSPACE_SSH_PORT}:22"
tty: true
environment:
...
- exec時に「tty使わないよ」と明示的に指定してやればよい
docker-compose exec --help
Execute a command in a running container
Usage: exec [options] SERVICE COMMAND [ARGS...]
Options:
-d Detached mode: Run command in the background.
--privileged Give extended privileges to the process.
-u, --user USER Run the command as this user.
-T Disable pseudo-tty allocation. By default `docker-compose exec`
allocates a TTY.
--index=index index of the container if there are multiple
instances of a service [default: 1]
-T Disable pseudo-tty allocation. By default `docker-compose exec`
allocates a TTY.
docker-compose exec -T --user=laradock workspace vendor/bin/phpunit
bash
で入れないので不便だが、外からphpunit
やartisan
を実行することはできる
根本的解決方法