-i标志被描述为“即使没有连接也保持STDIN打开”,但Docker run reference也说:
If you do not specify -a then Docker will attach all standard streams.
所以,默认情况下,stdin是附加的,但是没有打开?我认为STDIN连接但没有打开时没有任何意义,对吧?
与该文档相关的The exact code是:
原文链接:https://www.f2er.com/docker/436931.html// If neither -d or -a are set,attach to everything by default
if len(flAttach) == 0 && !*flDetach {
if !*flDetach {
flAttach.Set("stdout")
flAttach.Set("stderr")
if *flStdin {
flAttach.Set("stdin")
}
}
}
附:
flStdin := cmd.Bool("i",false,"Keep stdin open even if not attached")
换句话说,只有在设置-i时才附加stdin.
if *flStdin {
flAttach.Set("stdin")
}
从这个意义上讲,“所有”标准流并不准确.
如下所述,该代码(由doc引用)has since changed to:
cmd.Var(&flAttach,[]string{"a","-attach"},"Attach to STDIN,STDOUT or STDERR")
-a不再是男人“附上所有溪流”,但是“specify which streams you want attached”.
var (
attachStdin = flAttach.Get("stdin")
attachStdout = flAttach.Get("stdout")
attachStderr = flAttach.Get("stderr")
)
if *flStdin {
attachStdin = true
}