2014-08-09 22:30:27 +00:00
package daemon
2013-10-05 02:25:15 +00:00
import (
2014-08-10 01:18:32 +00:00
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
2015-02-04 19:04:58 +00:00
"github.com/docker/docker/runconfig"
2013-10-05 02:25:15 +00:00
)
2014-01-30 02:34:43 +00:00
const (
2014-02-01 11:38:39 +00:00
defaultNetworkMtu = 1500
2014-09-16 17:37:50 +00:00
disableNetworkBridge = "none"
2014-01-30 02:34:43 +00:00
)
2015-04-24 22:36:11 +00:00
// CommonConfig defines the configuration of a docker daemon which are
// common across platforms.
type CommonConfig struct {
2015-05-15 20:05:35 +00:00
AutoRestart bool
2015-07-13 19:34:58 +00:00
Bridge bridgeConfig // Bridge holds bridge network specific configuration.
2015-04-24 22:36:11 +00:00
Context map [ string ] [ ] string
2015-06-30 17:34:15 +00:00
DisableBridge bool
2015-07-30 21:01:53 +00:00
DNS [ ] string
DNSSearch [ ] string
2015-04-24 22:36:11 +00:00
ExecDriver string
2015-05-15 20:05:35 +00:00
ExecOptions [ ] string
2015-05-15 02:59:11 +00:00
ExecRoot string
2015-04-24 22:36:11 +00:00
GraphDriver string
2015-05-15 20:05:35 +00:00
GraphOptions [ ] string
2015-04-24 22:36:11 +00:00
Labels [ ] string
LogConfig runconfig . LogConfig
Mtu int
Pidfile string
Root string
TrustKeyPath string
2015-05-20 12:20:19 +00:00
DefaultNetwork string
2015-06-21 00:08:36 +00:00
NetworkKVStore string
2013-10-05 02:25:15 +00:00
}
2013-10-21 16:04:42 +00:00
2015-04-24 22:36:11 +00:00
// InstallCommonFlags adds command-line options to the top-level flag parser for
2014-08-10 01:18:32 +00:00
// the current process.
// Subsequent calls to `flag.Parse` will populate config with values parsed
// from the command-line.
2015-05-05 04:18:28 +00:00
func ( config * Config ) InstallCommonFlags ( cmd * flag . FlagSet , usageFn func ( string ) string ) {
cmd . Var ( opts . NewListOptsRef ( & config . GraphOptions , nil ) , [ ] string { "-storage-opt" } , usageFn ( "Set storage driver options" ) )
cmd . Var ( opts . NewListOptsRef ( & config . ExecOptions , nil ) , [ ] string { "-exec-opt" } , usageFn ( "Set exec driver options" ) )
cmd . StringVar ( & config . Pidfile , [ ] string { "p" , "-pidfile" } , defaultPidFile , usageFn ( "Path to use for daemon PID file" ) )
cmd . StringVar ( & config . Root , [ ] string { "g" , "-graph" } , defaultGraph , usageFn ( "Root of the Docker runtime" ) )
cmd . StringVar ( & config . ExecRoot , [ ] string { "-exec-root" } , "/var/run/docker" , usageFn ( "Root of the Docker execdriver" ) )
cmd . BoolVar ( & config . AutoRestart , [ ] string { "#r" , "#-restart" } , true , usageFn ( "--restart on the daemon has been deprecated in favor of --restart policies on docker run" ) )
cmd . StringVar ( & config . GraphDriver , [ ] string { "s" , "-storage-driver" } , "" , usageFn ( "Storage driver to use" ) )
cmd . StringVar ( & config . ExecDriver , [ ] string { "e" , "-exec-driver" } , defaultExec , usageFn ( "Exec driver to use" ) )
cmd . IntVar ( & config . Mtu , [ ] string { "#mtu" , "-mtu" } , 0 , usageFn ( "Set the containers network MTU" ) )
2014-08-10 01:18:32 +00:00
// FIXME: why the inconsistency between "hosts" and "sockets"?
2015-07-30 21:01:53 +00:00
cmd . Var ( opts . NewListOptsRef ( & config . DNS , opts . ValidateIPAddress ) , [ ] string { "#dns" , "-dns" } , usageFn ( "DNS server to use" ) )
cmd . Var ( opts . NewListOptsRef ( & config . DNSSearch , opts . ValidateDNSSearch ) , [ ] string { "-dns-search" } , usageFn ( "DNS search domains to use" ) )
2015-05-05 04:18:28 +00:00
cmd . Var ( opts . NewListOptsRef ( & config . Labels , opts . ValidateLabel ) , [ ] string { "-label" } , usageFn ( "Set key=value labels to the daemon" ) )
cmd . StringVar ( & config . LogConfig . Type , [ ] string { "-log-driver" } , "json-file" , usageFn ( "Default driver for container logs" ) )
cmd . Var ( opts . NewMapOpts ( config . LogConfig . Config , nil ) , [ ] string { "-log-opt" } , usageFn ( "Set log driver options" ) )
2014-08-10 01:18:32 +00:00
}