2015-07-29 14:25:56 -04:00
// +build linux freebsd
2015-04-24 18:36:11 -04:00
package daemon
import (
2015-05-15 16:05:35 -04:00
"net"
2015-04-24 18:36:11 -04:00
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
2015-12-21 15:06:46 -05:00
runconfigopts "github.com/docker/docker/runconfig/opts"
"github.com/docker/go-units"
2015-04-24 18:36:11 -04:00
)
var (
defaultPidFile = "/var/run/docker.pid"
defaultGraph = "/var/lib/docker"
2015-05-26 19:17:33 -04:00
defaultExec = "native"
2015-04-24 18:36:11 -04:00
)
// Config defines the configuration of a docker daemon.
type Config struct {
CommonConfig
// Fields below here are platform specific.
2015-05-15 16:05:35 -04:00
2015-07-16 17:14:58 -04:00
CorsHeaders string
EnableCors bool
2015-04-24 18:36:11 -04:00
EnableSelinuxSupport bool
2015-10-08 11:51:41 -04:00
RemappedRoot string
2015-04-24 18:36:11 -04:00
SocketGroup string
2015-12-07 12:55:33 -05:00
CgroupParent string
2015-12-21 15:06:46 -05:00
Ulimits map [ string ] * units . Ulimit
2015-04-24 18:36:11 -04:00
}
2015-05-15 16:05:35 -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
2015-06-05 01:57:59 -04:00
DefaultGatewayIPv4 net . IP
DefaultGatewayIPv6 net . IP
2015-05-15 16:05:35 -04:00
InterContainerCommunication bool
}
2015-04-24 18:36:11 -04:00
// InstallFlags adds command-line options to the top-level flag parser for
// 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 ) InstallFlags ( cmd * flag . FlagSet , usageFn func ( string ) string ) {
2015-04-24 18:36:11 -04:00
// First handle install flags which are consistent cross-platform
2015-05-05 00:18:28 -04:00
config . InstallCommonFlags ( cmd , usageFn )
2015-04-24 18:36:11 -04:00
// Then platform-specific install flags
2015-05-05 00:18:28 -04:00
cmd . BoolVar ( & config . EnableSelinuxSupport , [ ] string { "-selinux-enabled" } , false , usageFn ( "Enable selinux support" ) )
cmd . StringVar ( & config . SocketGroup , [ ] string { "G" , "-group" } , "docker" , usageFn ( "Group for the unix socket" ) )
2015-12-21 15:06:46 -05:00
config . Ulimits = make ( map [ string ] * units . Ulimit )
cmd . Var ( runconfigopts . NewUlimitOpt ( & config . Ulimits ) , [ ] string { "-default-ulimit" } , usageFn ( "Set default ulimits for containers" ) )
2015-05-05 00:18:28 -04:00
cmd . BoolVar ( & config . Bridge . EnableIPTables , [ ] string { "#iptables" , "-iptables" } , true , usageFn ( "Enable addition of iptables rules" ) )
cmd . BoolVar ( & config . Bridge . EnableIPForward , [ ] string { "#ip-forward" , "-ip-forward" } , true , usageFn ( "Enable net.ipv4.ip_forward" ) )
cmd . BoolVar ( & config . Bridge . EnableIPMasq , [ ] string { "-ip-masq" } , true , usageFn ( "Enable IP masquerading" ) )
cmd . BoolVar ( & config . Bridge . EnableIPv6 , [ ] string { "-ipv6" } , false , usageFn ( "Enable IPv6 networking" ) )
cmd . StringVar ( & config . Bridge . IP , [ ] string { "#bip" , "-bip" } , "" , usageFn ( "Specify network bridge IP" ) )
cmd . StringVar ( & config . Bridge . Iface , [ ] string { "b" , "-bridge" } , "" , usageFn ( "Attach containers to a network bridge" ) )
cmd . StringVar ( & config . Bridge . FixedCIDR , [ ] string { "-fixed-cidr" } , "" , usageFn ( "IPv4 subnet for fixed IPs" ) )
cmd . StringVar ( & config . Bridge . FixedCIDRv6 , [ ] string { "-fixed-cidr-v6" } , "" , usageFn ( "IPv6 subnet for fixed IPs" ) )
2015-07-28 14:18:04 -04:00
cmd . Var ( opts . NewIPOpt ( & config . Bridge . DefaultGatewayIPv4 , "" ) , [ ] string { "-default-gateway" } , usageFn ( "Container default gateway IPv4 address" ) )
cmd . Var ( opts . NewIPOpt ( & config . Bridge . DefaultGatewayIPv6 , "" ) , [ ] string { "-default-gateway-v6" } , usageFn ( "Container default gateway IPv6 address" ) )
2015-05-05 00:18:28 -04:00
cmd . BoolVar ( & config . Bridge . InterContainerCommunication , [ ] string { "#icc" , "-icc" } , true , usageFn ( "Enable inter-container communication" ) )
2015-07-28 14:18:04 -04:00
cmd . Var ( opts . NewIPOpt ( & config . Bridge . DefaultIP , "0.0.0.0" ) , [ ] string { "#ip" , "-ip" } , usageFn ( "Default IP when binding container ports" ) )
2015-09-16 12:55:14 -04:00
cmd . BoolVar ( & config . Bridge . EnableUserlandProxy , [ ] string { "-userland-proxy" } , true , usageFn ( "Use userland proxy for loopback traffic" ) )
2015-07-16 17:14:58 -04:00
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" ) )
cmd . StringVar ( & config . CorsHeaders , [ ] string { "-api-cors-header" } , "" , usageFn ( "Set CORS headers in the remote API" ) )
2016-01-06 16:59:01 -05:00
cmd . StringVar ( & config . CgroupParent , [ ] string { "-cgroup-parent" } , "" , usageFn ( "Set parent cgroup for all containers" ) )
2015-10-08 11:51:41 -04:00
config . attachExperimentalFlags ( cmd , usageFn )
2015-04-24 18:36:11 -04:00
}