混淆了docker的-i“即使未连接也保持STDIN打开". [英] Confuse about docker's -i "Keep STDIN open even if not attached"

查看:55
本文介绍了混淆了docker的-i“即使未连接也保持STDIN打开".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-i 标志被描述为即使未连接也保持STDIN打开",但是 Docker运行参考还说:

The -i flag is described as "Keep STDIN open even if not attached", but Docker run reference also says:

如果您未指定-a,则Docker将附加所有标准流.

If you do not specify -a then Docker will attach all standard streams.

那么,默认情况下,标准输入是附加的,但没有打开?我认为连接STDIN但未打开时没有任何意义,对吧?

So, by default, stdin is attached, but not opened? I think it doesn't make any sense when STDIN is attached but not opened, right?

推荐答案

使用:

flStdin := cmd.Bool("i", false, "Keep stdin open even if not attached")

换句话说,如果设置了 -i ,则仅 附加stdin.

In other words, stdin is attached only if -i is set.

        if *flStdin {
            flAttach.Set("stdin")
        }

从这种意义上讲,所有"标准流都不准确.

In that sense, "all" standard streams isn't accurate.

如下所述,该代码(由文档引用)

As commented below, that code (referenced by the doc) has since changed to:

cmd.Var(&flAttach, []string{"a", "-attach"}, "Attach to STDIN, STDOUT or STDERR")

-a 不再附加所有流",而是.

-a does not man anymore "attach all streams", but "specify which streams you want attached".

var (
    attachStdin  = flAttach.Get("stdin")
    attachStdout = flAttach.Get("stdout")
    attachStderr = flAttach.Get("stderr")
)

-i 仍然是有效选项:

-i remains a valid option:

if *flStdin {
    attachStdin = true
}

这篇关于混淆了docker的-i“即使未连接也保持STDIN打开".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆