github.com/chenchun/docker@v1.3.2-0.20150629222414-20467faf132b/daemon/config.go (about) 1 package daemon 2 3 import ( 4 "github.com/docker/docker/opts" 5 flag "github.com/docker/docker/pkg/mflag" 6 "github.com/docker/docker/runconfig" 7 ) 8 9 const ( 10 defaultNetworkMtu = 1500 11 disableNetworkBridge = "none" 12 ) 13 14 // CommonConfig defines the configuration of a docker daemon which are 15 // common across platforms. 16 type CommonConfig struct { 17 AutoRestart bool 18 Context map[string][]string 19 CorsHeaders string 20 DisableNetwork bool 21 Dns []string 22 DnsSearch []string 23 EnableCors bool 24 ExecDriver string 25 ExecOptions []string 26 ExecRoot string 27 GraphDriver string 28 GraphOptions []string 29 Labels []string 30 LogConfig runconfig.LogConfig 31 Mtu int 32 Pidfile string 33 Root string 34 TrustKeyPath string 35 DefaultNetwork string 36 NetworkKVStore string 37 } 38 39 // InstallCommonFlags adds command-line options to the top-level flag parser for 40 // the current process. 41 // Subsequent calls to `flag.Parse` will populate config with values parsed 42 // from the command-line. 43 func (config *Config) InstallCommonFlags() { 44 opts.ListVar(&config.GraphOptions, []string{"-storage-opt"}, "Set storage driver options") 45 opts.ListVar(&config.ExecOptions, []string{"-exec-opt"}, "Set exec driver options") 46 flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, defaultPidFile, "Path to use for daemon PID file") 47 flag.StringVar(&config.Root, []string{"g", "-graph"}, defaultGraph, "Root of the Docker runtime") 48 flag.StringVar(&config.ExecRoot, []string{"-exec-root"}, "/var/run/docker", "Root of the Docker execdriver") 49 flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run") 50 flag.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", "Storage driver to use") 51 flag.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, defaultExec, "Exec driver to use") 52 flag.IntVar(&config.Mtu, []string{"#mtu", "-mtu"}, 0, "Set the containers network MTU") 53 flag.BoolVar(&config.EnableCors, []string{"#api-enable-cors", "#-api-enable-cors"}, false, "Enable CORS headers in the remote API, this is deprecated by --api-cors-header") 54 flag.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", "Set CORS headers in the remote API") 55 // FIXME: why the inconsistency between "hosts" and "sockets"? 56 opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "DNS server to use") 57 opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "DNS search domains to use") 58 opts.LabelListVar(&config.Labels, []string{"-label"}, "Set key=value labels to the daemon") 59 flag.StringVar(&config.LogConfig.Type, []string{"-log-driver"}, "json-file", "Default driver for container logs") 60 opts.LogOptsVar(config.LogConfig.Config, []string{"-log-opt"}, "Set log driver options") 61 }