2014-08-09 18:30:27 -04:00
package daemon
2013-10-04 22:25:15 -04:00
import (
2014-08-09 21:18:32 -04:00
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
2016-01-04 19:05:26 -05:00
"github.com/docker/engine-api/types/container"
2013-10-04 22:25:15 -04:00
)
2014-01-29 21:34:43 -05:00
const (
2014-02-01 06:38:39 -05:00
defaultNetworkMtu = 1500
2014-09-16 13:37:50 -04:00
disableNetworkBridge = "none"
2014-01-29 21:34:43 -05:00
)
2015-04-24 18:36:11 -04:00
// CommonConfig defines the configuration of a docker daemon which are
// common across platforms.
type CommonConfig struct {
2016-01-12 19:38:18 -05:00
AuthorizationPlugins [ ] string // AuthorizationPlugins holds list of authorization plugins
AutoRestart bool
Bridge bridgeConfig // Bridge holds bridge network specific configuration.
Context map [ string ] [ ] string
DisableBridge bool
DNS [ ] string
DNSOptions [ ] string
DNSSearch [ ] string
ExecOptions [ ] string
ExecRoot string
GraphDriver string
GraphOptions [ ] string
Labels [ ] string
LogConfig container . LogConfig
Mtu int
Pidfile string
RemappedRoot string
Root string
TrustKeyPath string
2015-09-10 19:12:00 -04:00
// ClusterStore is the storage backend used for the cluster information. It is used by both
// multihost networking (to store networks and endpoints information) and by the node discovery
// mechanism.
ClusterStore string
2015-09-28 19:22:57 -04:00
// ClusterOpts is used to pass options to the discovery package for tuning libkv settings, such
// as TLS configuration settings.
ClusterOpts map [ string ] string
2015-09-10 19:12:00 -04:00
// ClusterAdvertise is the network endpoint that the Engine advertises for the purpose of node
// discovery. This should be a 'host:port' combination on which that daemon instance is
// reachable by other hosts.
ClusterAdvertise string
2013-10-04 22:25:15 -04:00
}
2013-10-21 12:04:42 -04:00
2015-04-24 18:36:11 -04:00
// InstallCommonFlags adds command-line options to the top-level flag parser for
2014-08-09 21:18:32 -04:00
// the current process.
// Subsequent calls to `flag.Parse` will populate config with values parsed
// from the command-line.
2015-05-05 00:18:28 -04: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" ) )
2016-01-12 19:38:18 -05:00
cmd . Var ( opts . NewListOptsRef ( & config . AuthorizationPlugins , nil ) , [ ] string { "-authorization-plugin" } , usageFn ( "List authorization plugins in order from first evaluator to last" ) )
2015-05-05 00:18:28 -04:00
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 . IntVar ( & config . Mtu , [ ] string { "#mtu" , "-mtu" } , 0 , usageFn ( "Set the containers network MTU" ) )
2014-08-09 21:18:32 -04:00
// FIXME: why the inconsistency between "hosts" and "sockets"?
2015-07-30 17:01:53 -04:00
cmd . Var ( opts . NewListOptsRef ( & config . DNS , opts . ValidateIPAddress ) , [ ] string { "#dns" , "-dns" } , usageFn ( "DNS server to use" ) )
2015-08-31 14:47:25 -04:00
cmd . Var ( opts . NewListOptsRef ( & config . DNSOptions , nil ) , [ ] string { "-dns-opt" } , usageFn ( "DNS options to use" ) )
2015-07-30 17:01:53 -04:00
cmd . Var ( opts . NewListOptsRef ( & config . DNSSearch , opts . ValidateDNSSearch ) , [ ] string { "-dns-search" } , usageFn ( "DNS search domains to use" ) )
2015-05-05 00:18:28 -04: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" ) )
2015-10-25 20:12:22 -04:00
cmd . StringVar ( & config . ClusterAdvertise , [ ] string { "-cluster-advertise" } , "" , usageFn ( "Address or interface name to advertise" ) )
2015-09-10 19:12:00 -04:00
cmd . StringVar ( & config . ClusterStore , [ ] string { "-cluster-store" } , "" , usageFn ( "Set the cluster store" ) )
2015-09-28 19:22:57 -04:00
cmd . Var ( opts . NewMapOpts ( config . ClusterOpts , nil ) , [ ] string { "-cluster-store-opt" } , usageFn ( "Set cluster store options" ) )
2014-08-09 21:18:32 -04:00
}