2014-08-09 18:30:27 -04:00
package daemon
2013-10-04 22:25:15 -04:00
import (
2015-05-06 18:39:29 -04:00
"net"
2014-08-09 21:18:32 -04:00
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
2015-02-04 14:04:58 -05:00
"github.com/docker/docker/runconfig"
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 {
2015-05-06 18:39:29 -04:00
AutoRestart bool
// Bridge holds bridge network specific configuration.
Bridge bridgeConfig
2015-04-24 18:36:11 -04:00
Context map [ string ] [ ] string
CorsHeaders string
DisableNetwork bool
Dns [ ] string
DnsSearch [ ] string
EnableCors bool
ExecDriver string
2015-05-14 22:59:11 -04:00
ExecRoot string
2015-04-24 18:36:11 -04:00
GraphDriver string
Labels [ ] string
LogConfig runconfig . LogConfig
Mtu int
Pidfile string
Root string
TrustKeyPath string
2013-10-04 22:25:15 -04:00
}
2013-10-21 12:04:42 -04:00
2015-05-06 18:39:29 -04:00
// bridgeConfig stores all the bridge driver specific
// configuration.
type bridgeConfig struct {
EnableIPv6 bool
EnableIPTables bool
EnableIPForward bool
EnableIPMasq bool
EnableUserlandProxy bool
DefaultIP net . IP
Iface string
IP string
FixedCIDR string
FixedCIDRv6 string
DefaultGatewayIPv4 string
DefaultGatewayIPv6 string
InterContainerCommunication bool
}
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-14 22:59:11 -04:00
2015-04-24 18:36:11 -04:00
func ( config * Config ) InstallCommonFlags ( ) {
flag . StringVar ( & config . Pidfile , [ ] string { "p" , "-pidfile" } , defaultPidFile , "Path to use for daemon PID file" )
flag . StringVar ( & config . Root , [ ] string { "g" , "-graph" } , defaultGraph , "Root of the Docker runtime" )
2015-05-14 22:59:11 -04:00
flag . StringVar ( & config . ExecRoot , [ ] string { "-exec-root" } , "/var/run/docker" , "Root of the Docker execdriver" )
2014-08-22 15:56:43 -04:00
flag . BoolVar ( & config . AutoRestart , [ ] string { "#r" , "#-restart" } , true , "--restart on the daemon has been deprecated in favor of --restart policies on docker run" )
2015-05-06 18:39:29 -04:00
flag . BoolVar ( & config . Bridge . EnableIPTables , [ ] string { "#iptables" , "-iptables" } , true , "Enable addition of iptables rules" )
flag . BoolVar ( & config . Bridge . EnableIPForward , [ ] string { "#ip-forward" , "-ip-forward" } , true , "Enable net.ipv4.ip_forward" )
flag . BoolVar ( & config . Bridge . EnableIPMasq , [ ] string { "-ip-masq" } , true , "Enable IP masquerading" )
2015-04-04 00:06:48 -04:00
flag . BoolVar ( & config . Bridge . EnableIPv6 , [ ] string { "-ipv6" } , false , "Enable IPv6 networking" )
flag . StringVar ( & config . Bridge . IP , [ ] string { "#bip" , "-bip" } , "" , "Specify network bridge IP" )
flag . StringVar ( & config . Bridge . Iface , [ ] string { "b" , "-bridge" } , "" , "Attach containers to a network bridge" )
flag . StringVar ( & config . Bridge . FixedCIDR , [ ] string { "-fixed-cidr" } , "" , "IPv4 subnet for fixed IPs" )
flag . StringVar ( & config . Bridge . FixedCIDRv6 , [ ] string { "-fixed-cidr-v6" } , "" , "IPv6 subnet for fixed IPs" )
2014-12-18 04:09:42 -05:00
flag . StringVar ( & config . Bridge . DefaultGatewayIPv4 , [ ] string { "-default-gateway" } , "" , "Container default gateway IPv4 address" )
flag . StringVar ( & config . Bridge . DefaultGatewayIPv6 , [ ] string { "-default-gateway-v6" } , "" , "Container default gateway IPv6 address" )
2015-04-04 00:06:48 -04:00
flag . BoolVar ( & config . Bridge . InterContainerCommunication , [ ] string { "#icc" , "-icc" } , true , "Enable inter-container communication" )
2015-02-03 22:51:35 -05:00
flag . StringVar ( & config . GraphDriver , [ ] string { "s" , "-storage-driver" } , "" , "Storage driver to use" )
2015-05-26 19:17:33 -04:00
flag . StringVar ( & config . ExecDriver , [ ] string { "e" , "-exec-driver" } , defaultExec , "Exec driver to use" )
2015-02-03 22:51:35 -05:00
flag . IntVar ( & config . Mtu , [ ] string { "#mtu" , "-mtu" } , 0 , "Set the containers network MTU" )
2015-02-27 00:38:16 -05:00
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" )
2015-02-09 02:15:07 -05:00
flag . StringVar ( & config . CorsHeaders , [ ] string { "-api-cors-header" } , "" , "Set CORS headers in the remote API" )
2015-05-06 18:39:29 -04:00
opts . IPVar ( & config . Bridge . DefaultIP , [ ] string { "#ip" , "-ip" } , "0.0.0.0" , "Default IP when binding container ports" )
2014-08-09 21:18:32 -04:00
// FIXME: why the inconsistency between "hosts" and "sockets"?
2015-02-03 22:51:35 -05:00
opts . IPListVar ( & config . Dns , [ ] string { "#dns" , "-dns" } , "DNS server to use" )
opts . DnsSearchListVar ( & config . DnsSearch , [ ] string { "-dns-search" } , "DNS search domains to use" )
opts . LabelListVar ( & config . Labels , [ ] string { "-label" } , "Set key=value labels to the daemon" )
2015-04-08 19:37:39 -04:00
flag . StringVar ( & config . LogConfig . Type , [ ] string { "-log-driver" } , "json-file" , "Default driver for container logs" )
2015-05-04 17:39:48 -04:00
opts . LogOptsVar ( config . LogConfig . Config , [ ] string { "-log-opt" } , "Set log driver options" )
2015-04-24 18:36:11 -04:00
flag . BoolVar ( & config . Bridge . EnableUserlandProxy , [ ] string { "-userland-proxy" } , true , "Use userland proxy for loopback traffic" )
2014-08-09 21:18:32 -04:00
}