環境
- Windows10
- Docker Desktop for Windows
- Laradock
-
cmdでもPowerShellでもないshell
- Emacs Shell
- GitBash
現象
- 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
フラグが指定されている- 指定しないと即
EXIT 0
してしまう
- 指定しないと即
### Workspace Utilities ##################################
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 --user=laradock workspace vendor/bin/phpunit
docker-compose exec -T --user=laradock workspace vendor/bin/phpunit
bash
で入れないので不便だが、外からphpunit
やartisan
を実行することはできる
根本的解決方法
- WindowsをアンインストールしてLinuxをインストールする