docker(moby)源码解析 --dockerd

docker.go:

    main:

        newDaemonCommand()    //创建daemonOptions结构体

             runDaemon(opts):

                 daemonCli := NewDaemonCli()    // 创建DaemonCli结构体

                  stop, runAsService, err := initService(daemonCli) //windows使用,忽略

                   err = daemonCli.start(opts)  //

                        opts.SetDefaultOptions(opts.flags)

                         loadDaemonCliConfig(opts)    // 填充config

                                  if conf.TrustKeyPath = "" {conf.TrustKeyPath= "/etc/docker/key.json"}

                                  if flags.Changed("graph") && flags.Changed("data-root")

                                  if opts.configFile != ""{

                                          c, err := config.MergeDaemonConfigurations(conf, flags, opts.configFile)}    //读取配置文件,将文件加载到一个独立结构体

                                  if err := config.Validate(conf)//验证一些特定配置,如dns等

                          if err := setDefaultUmask()//设置文件权限,644权限

                          if err := daemon.CreateDaemonRoot(cli.Config)//创建root给daemon

                          if cli.Pidfile != ""//创建pid文件

                            

                        


                            


你可能感兴趣的:(docker)