docker错误



错误:cannot enable tty mode on non tty input

错误产生:

root@machine1:/data# echo test|docker exec -i 68b cat  test 

root@machine1:/data# echo test|docker exec -it 68b cat 

cannot enable tty mode on non tty input

问题在于,当使用-it时,容器为我们分配了伪终端,等待我们从终端输入数据到伪终端的标准输入。但我们的输入方式却不是从终端,有可能是重定向和管道。官网对于it参数的解释:

But we’ve also passed in two flags:  -t  and  -i . The  -t  flag assigns a pseudo-tty or terminal inside our new container and the  -i  flag allows us to make an interactive connection by grabbing the standard in ( STDIN ) of the container.


In foreground mode (the default when -d is not specified), docker run can start the process in the container and attach the console to the process’s standard input, output, and standard error. It can even pretend to be a TTY (this is what most command line executables expect) and pass along signals. All of that is configurable:

-a=[]           : Attach to `STDIN`, `STDOUT` and/or `STDERR`
-t=false        : Allocate a pseudo-tty
--sig-proxy=true: Proxify all received signal to the process (non-TTY mode only)
-i=false        : Keep STDIN open even if not attached

If you do not specify -a then Docker will attach all standard streams. You can specify to which of the three standard streams (STDINSTDOUTSTDERR) you’d like to connect instead, as in:

$ docker run -a stdin -a stdout -i -t ubuntu /bin/bash

For interactive processes (like a shell), you must use -i -ttogether in order to allocate a tty for the container process. -i -t is often written -it as you’ll see in later examples. Specifying -t is forbidden when the client standard output is redirected or piped, such as in: echo test | docker run -i busybox cat.

解决方法:某些情况下it不能同时使用


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值