我正在尝试将SQL数据导入到docker容器中。使用git bash / mintty:
> docker exec -it 79c5c16acca0 mysql -uusername -ppassword dbname
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'
> winpty docker exec -it 79c5c16acca0 mysql -uusername -ppassword dbname
stdin is not a tty我也尝试过Powershell:
> Get-Content powo.sql | docker exec -it 79c5c16acca0 mysql -uusername -ppassword dbname
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'FWIW,在容器中运行bash运行良好:
> docker exec -it 79c5c16acca0 bash
root@79c5c16acca0:/#发布于 2021-01-12 00:46:08
如果您删除了-t,这将会起作用。
$ docker run --rm --name example alpine sleep 100
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
49968909e3e4 alpine "sleep 100" 8 seconds ago Up 7 seconds example
$ echo "hi" | docker exec -it example cat
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'
$ echo "hi" | docker exec -i example cat
hi对于bash、ps和Git bash也是如此。
这个answer是我能找到的关于-i和-t做什么的最好的参考资料(用我能理解的语言)。
因此,我猜测在通过管道输入内容时不能使用-t,因为-t意味着输入来自终端设备,但在本例中,输入是管道(它本身来自终端设备)。
https://stackoverflow.com/questions/65668498
复制相似问题