Docker源码解读:1.flag解读
我是怎么想到要先看docker中的flag呢,就是因为docker采用了c/s结构,而且daemon和client都是用同一个程序的,因此,为了做出区分,肯定是要用参数来区分的。先来看位于./docker/docker/docker.go下面的main函数代码: func main() { //第一次肯定是返回false的,因为没有任何initializer if reexec.Init() { return } // Set terminal emulation based on platform as required. stdin, stdout, stderr := term.StdStreams() logrus.SetOutput(stderr) flag.Merge(flag.CommandLine, clientFlags.FlagSet, commonFlags.FlagSet) flag.Usage = func() { fmt.Fprint(os.Stdout, "Usage: docker [OPTIONS] COMMAND [arg...]\n"+daemonUsage+" docker [ --help | -v | --version ]\n\n") fmt.Fprint(os.Stdout, "A self-sufficient runtime