确切的代码 https://github.com/docker/docker/blob/75a7f4d90cde0295bcfb7213004abce8d4779b75/commands.go#L1797-L1806与该文档相关的是:
// 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")
}
}
}
With:
flStdin := cmd.Bool("i", false, "Keep stdin open even if not attached")
换句话说,stdin 已附加only if -i
is set.
if *flStdin {
flAttach.Set("stdin")
}
从这个意义上说,“所有”标准流并不准确。
如下所述,该代码(由文档引用)此后改为 https://github.com/docker/docker/blob/07f580489908bf6a3373daac1473045406e1130d/runconfig/opts/parse.go#L102:
cmd.Var(&flAttach, []string{"a", "-attach"}, "Attach to STDIN, STDOUT or STDERR")
-a
不再有人“附加所有流”,但是“指定您想要附加的流” https://github.com/docker/docker/blob/07f580489908bf6a3373daac1473045406e1130d/runconfig/opts/parse.go#L138-L142.
var (
attachStdin = flAttach.Get("stdin")
attachStdout = flAttach.Get("stdout")
attachStderr = flAttach.Get("stderr")
)
-i仍然是一个有效的选项 https://github.com/docker/docker/blob/07f580489908bf6a3373daac1473045406e1130d/runconfig/opts/parse.go#L150-L152:
if *flStdin {
attachStdin = true
}