github.com/akashshinde/docker@v1.9.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  	DisableBridge  bool
    21  	DNS            []string
    22  	DNSOptions     []string
    23  	DNSSearch      []string
    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  	RemappedRoot   string
    34  	Root           string
    35  	TrustKeyPath   string
    36  	DefaultNetwork string
    37  
    38  	// ClusterStore is the storage backend used for the cluster information. It is used by both
    39  	// multihost networking (to store networks and endpoints information) and by the node discovery
    40  	// mechanism.
    41  	ClusterStore string
    42  
    43  	// ClusterOpts is used to pass options to the discovery package for tuning libkv settings, such
    44  	// as TLS configuration settings.
    45  	ClusterOpts map[string]string
    46  
    47  	// ClusterAdvertise is the network endpoint that the Engine advertises for the purpose of node
    48  	// discovery. This should be a 'host:port' combination on which that daemon instance is
    49  	// reachable by other hosts.
    50  	ClusterAdvertise string
    51  }
    52  
    53  // InstallCommonFlags adds command-line options to the top-level flag parser for
    54  // the current process.
    55  // Subsequent calls to `flag.Parse` will populate config with values parsed
    56  // from the command-line.
    57  func (config *Config) InstallCommonFlags(cmd *flag.FlagSet, usageFn func(string) string) {
    58  	cmd.Var(opts.NewListOptsRef(&config.GraphOptions, nil), []string{"-storage-opt"}, usageFn("Set storage driver options"))
    59  	cmd.Var(opts.NewListOptsRef(&config.ExecOptions, nil), []string{"-exec-opt"}, usageFn("Set exec driver options"))
    60  	cmd.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, defaultPidFile, usageFn("Path to use for daemon PID file"))
    61  	cmd.StringVar(&config.Root, []string{"g", "-graph"}, defaultGraph, usageFn("Root of the Docker runtime"))
    62  	cmd.StringVar(&config.ExecRoot, []string{"-exec-root"}, "/var/run/docker", usageFn("Root of the Docker execdriver"))
    63  	cmd.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, usageFn("--restart on the daemon has been deprecated in favor of --restart policies on docker run"))
    64  	cmd.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", usageFn("Storage driver to use"))
    65  	cmd.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, defaultExec, usageFn("Exec driver to use"))
    66  	cmd.IntVar(&config.Mtu, []string{"#mtu", "-mtu"}, 0, usageFn("Set the containers network MTU"))
    67  	// FIXME: why the inconsistency between "hosts" and "sockets"?
    68  	cmd.Var(opts.NewListOptsRef(&config.DNS, opts.ValidateIPAddress), []string{"#dns", "-dns"}, usageFn("DNS server to use"))
    69  	cmd.Var(opts.NewListOptsRef(&config.DNSOptions, nil), []string{"-dns-opt"}, usageFn("DNS options to use"))
    70  	cmd.Var(opts.NewListOptsRef(&config.DNSSearch, opts.ValidateDNSSearch), []string{"-dns-search"}, usageFn("DNS search domains to use"))
    71  	cmd.Var(opts.NewListOptsRef(&config.Labels, opts.ValidateLabel), []string{"-label"}, usageFn("Set key=value labels to the daemon"))
    72  	cmd.StringVar(&config.LogConfig.Type, []string{"-log-driver"}, "json-file", usageFn("Default driver for container logs"))
    73  	cmd.Var(opts.NewMapOpts(config.LogConfig.Config, nil), []string{"-log-opt"}, usageFn("Set log driver options"))
    74  	cmd.StringVar(&config.ClusterAdvertise, []string{"-cluster-advertise"}, "", usageFn("Address or interface name to advertise"))
    75  	cmd.StringVar(&config.ClusterStore, []string{"-cluster-store"}, "", usageFn("Set the cluster store"))
    76  	cmd.Var(opts.NewMapOpts(config.ClusterOpts, nil), []string{"-cluster-store-opt"}, usageFn("Set cluster store options"))
    77  }