github.com/willmtemple/docker@v1.7.0-rc2/daemon/config.go (about) 1 package daemon 2 3 import ( 4 "net" 5 6 "github.com/docker/docker/opts" 7 flag "github.com/docker/docker/pkg/mflag" 8 "github.com/docker/docker/runconfig" 9 ) 10 11 const ( 12 defaultNetworkMtu = 1500 13 disableNetworkBridge = "none" 14 ) 15 16 // CommonConfig defines the configuration of a docker daemon which are 17 // common across platforms. 18 type CommonConfig struct { 19 AutoRestart bool 20 // Bridge holds bridge network specific configuration. 21 Bridge bridgeConfig 22 Context map[string][]string 23 CorsHeaders string 24 DisableNetwork bool 25 Dns []string 26 DnsSearch []string 27 EnableCors bool 28 ExecDriver string 29 ExecRoot string 30 GraphDriver string 31 Labels []string 32 LogConfig runconfig.LogConfig 33 Mtu int 34 Pidfile string 35 Root string 36 TrustKeyPath string 37 } 38 39 // bridgeConfig stores all the bridge driver specific 40 // configuration. 41 type bridgeConfig struct { 42 EnableIPv6 bool 43 EnableIPTables bool 44 EnableIPForward bool 45 EnableIPMasq bool 46 EnableUserlandProxy bool 47 DefaultIP net.IP 48 Iface string 49 IP string 50 FixedCIDR string 51 FixedCIDRv6 string 52 DefaultGatewayIPv4 string 53 DefaultGatewayIPv6 string 54 InterContainerCommunication bool 55 } 56 57 // InstallCommonFlags adds command-line options to the top-level flag parser for 58 // the current process. 59 // Subsequent calls to `flag.Parse` will populate config with values parsed 60 // from the command-line. 61 62 func (config *Config) InstallCommonFlags() { 63 flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, defaultPidFile, "Path to use for daemon PID file") 64 flag.StringVar(&config.Root, []string{"g", "-graph"}, defaultGraph, "Root of the Docker runtime") 65 flag.StringVar(&config.ExecRoot, []string{"-exec-root"}, "/var/run/docker", "Root of the Docker execdriver") 66 flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run") 67 flag.BoolVar(&config.Bridge.EnableIPTables, []string{"#iptables", "-iptables"}, true, "Enable addition of iptables rules") 68 flag.BoolVar(&config.Bridge.EnableIPForward, []string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward") 69 flag.BoolVar(&config.Bridge.EnableIPMasq, []string{"-ip-masq"}, true, "Enable IP masquerading") 70 flag.BoolVar(&config.Bridge.EnableIPv6, []string{"-ipv6"}, false, "Enable IPv6 networking") 71 flag.StringVar(&config.Bridge.IP, []string{"#bip", "-bip"}, "", "Specify network bridge IP") 72 flag.StringVar(&config.Bridge.Iface, []string{"b", "-bridge"}, "", "Attach containers to a network bridge") 73 flag.StringVar(&config.Bridge.FixedCIDR, []string{"-fixed-cidr"}, "", "IPv4 subnet for fixed IPs") 74 flag.StringVar(&config.Bridge.FixedCIDRv6, []string{"-fixed-cidr-v6"}, "", "IPv6 subnet for fixed IPs") 75 flag.StringVar(&config.Bridge.DefaultGatewayIPv4, []string{"-default-gateway"}, "", "Container default gateway IPv4 address") 76 flag.StringVar(&config.Bridge.DefaultGatewayIPv6, []string{"-default-gateway-v6"}, "", "Container default gateway IPv6 address") 77 flag.BoolVar(&config.Bridge.InterContainerCommunication, []string{"#icc", "-icc"}, true, "Enable inter-container communication") 78 flag.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", "Storage driver to use") 79 flag.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, defaultExec, "Exec driver to use") 80 flag.IntVar(&config.Mtu, []string{"#mtu", "-mtu"}, 0, "Set the containers network MTU") 81 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") 82 flag.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", "Set CORS headers in the remote API") 83 opts.IPVar(&config.Bridge.DefaultIP, []string{"#ip", "-ip"}, "0.0.0.0", "Default IP when binding container ports") 84 // FIXME: why the inconsistency between "hosts" and "sockets"? 85 opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "DNS server to use") 86 opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "DNS search domains to use") 87 opts.LabelListVar(&config.Labels, []string{"-label"}, "Set key=value labels to the daemon") 88 flag.StringVar(&config.LogConfig.Type, []string{"-log-driver"}, "json-file", "Default driver for container logs") 89 opts.LogOptsVar(config.LogConfig.Config, []string{"-log-opt"}, "Set log driver options") 90 flag.BoolVar(&config.Bridge.EnableUserlandProxy, []string{"-userland-proxy"}, true, "Use userland proxy for loopback traffic") 91 92 }