github.com/torfuzx/docker@v1.8.1/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  	Bridge         bridgeConfig // Bridge holds bridge network specific configuration.
    19  	Context        map[string][]string
    20  	CorsHeaders    string
    21  	DisableBridge  bool
    22  	Dns            []string
    23  	DnsSearch      []string
    24  	EnableCors     bool
    25  	ExecDriver     string
    26  	ExecOptions    []string
    27  	ExecRoot       string
    28  	GraphDriver    string
    29  	GraphOptions   []string
    30  	Labels         []string
    31  	LogConfig      runconfig.LogConfig
    32  	Mtu            int
    33  	Pidfile        string
    34  	Root           string
    35  	TrustKeyPath   string
    36  	DefaultNetwork string
    37  	NetworkKVStore string
    38  }
    39  
    40  // InstallCommonFlags adds command-line options to the top-level flag parser for
    41  // the current process.
    42  // Subsequent calls to `flag.Parse` will populate config with values parsed
    43  // from the command-line.
    44  func (config *Config) InstallCommonFlags(cmd *flag.FlagSet, usageFn func(string) string) {
    45  	cmd.Var(opts.NewListOptsRef(&config.GraphOptions, nil), []string{"-storage-opt"}, usageFn("Set storage driver options"))
    46  	cmd.Var(opts.NewListOptsRef(&config.ExecOptions, nil), []string{"-exec-opt"}, usageFn("Set exec driver options"))
    47  	cmd.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, defaultPidFile, usageFn("Path to use for daemon PID file"))
    48  	cmd.StringVar(&config.Root, []string{"g", "-graph"}, defaultGraph, usageFn("Root of the Docker runtime"))
    49  	cmd.StringVar(&config.ExecRoot, []string{"-exec-root"}, "/var/run/docker", usageFn("Root of the Docker execdriver"))
    50  	cmd.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, usageFn("--restart on the daemon has been deprecated in favor of --restart policies on docker run"))
    51  	cmd.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", usageFn("Storage driver to use"))
    52  	cmd.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, defaultExec, usageFn("Exec driver to use"))
    53  	cmd.IntVar(&config.Mtu, []string{"#mtu", "-mtu"}, 0, usageFn("Set the containers network MTU"))
    54  	cmd.BoolVar(&config.EnableCors, []string{"#api-enable-cors", "#-api-enable-cors"}, false, usageFn("Enable CORS headers in the remote API, this is deprecated by --api-cors-header"))
    55  	cmd.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", usageFn("Set CORS headers in the remote API"))
    56  	// FIXME: why the inconsistency between "hosts" and "sockets"?
    57  	cmd.Var(opts.NewListOptsRef(&config.Dns, opts.ValidateIPAddress), []string{"#dns", "-dns"}, usageFn("DNS server to use"))
    58  	cmd.Var(opts.NewListOptsRef(&config.DnsSearch, opts.ValidateDNSSearch), []string{"-dns-search"}, usageFn("DNS search domains to use"))
    59  	cmd.Var(opts.NewListOptsRef(&config.Labels, opts.ValidateLabel), []string{"-label"}, usageFn("Set key=value labels to the daemon"))
    60  	cmd.StringVar(&config.LogConfig.Type, []string{"-log-driver"}, "json-file", usageFn("Default driver for container logs"))
    61  	cmd.Var(opts.NewMapOpts(config.LogConfig.Config, nil), []string{"-log-opt"}, usageFn("Set log driver options"))
    62  }