github.com/fcwu/docker@v1.4.2-0.20150115145920-2a69ca89f0df/daemon/config.go (about) 1 package daemon 2 3 import ( 4 "net" 5 6 "github.com/docker/docker/daemon/networkdriver" 7 "github.com/docker/docker/opts" 8 flag "github.com/docker/docker/pkg/mflag" 9 ) 10 11 const ( 12 defaultNetworkMtu = 1500 13 disableNetworkBridge = "none" 14 ) 15 16 // Config define the configuration of a docker daemon 17 // These are the configuration settings that you pass 18 // to the docker daemon when you launch it with say: `docker -d -e lxc` 19 // FIXME: separate runtime configuration from http api configuration 20 type Config struct { 21 Pidfile string 22 Root string 23 AutoRestart bool 24 Dns []string 25 DnsSearch []string 26 Mirrors []string 27 EnableIptables bool 28 EnableIpForward bool 29 EnableIpMasq bool 30 DefaultIp net.IP 31 BridgeIface string 32 BridgeIP string 33 FixedCIDR string 34 InsecureRegistries []string 35 InterContainerCommunication bool 36 GraphDriver string 37 GraphOptions []string 38 ExecDriver string 39 Mtu int 40 DisableNetwork bool 41 EnableSelinuxSupport bool 42 Context map[string][]string 43 TrustKeyPath string 44 Labels []string 45 } 46 47 // InstallFlags adds command-line options to the top-level flag parser for 48 // the current process. 49 // Subsequent calls to `flag.Parse` will populate config with values parsed 50 // from the command-line. 51 func (config *Config) InstallFlags() { 52 flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file") 53 flag.StringVar(&config.Root, []string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the Docker runtime") 54 flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run") 55 flag.BoolVar(&config.EnableIptables, []string{"#iptables", "-iptables"}, true, "Enable Docker's addition of iptables rules") 56 flag.BoolVar(&config.EnableIpForward, []string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward") 57 flag.BoolVar(&config.EnableIpMasq, []string{"-ip-masq"}, true, "Enable IP masquerading for bridge's IP range") 58 flag.StringVar(&config.BridgeIP, []string{"#bip", "-bip"}, "", "Use this CIDR notation address for the network bridge's IP, not compatible with -b") 59 flag.StringVar(&config.BridgeIface, []string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge\nuse 'none' to disable container networking") 60 flag.StringVar(&config.FixedCIDR, []string{"-fixed-cidr"}, "", "IPv4 subnet for fixed IPs (ex: 10.20.0.0/16)\nthis subnet must be nested in the bridge subnet (which is defined by -b or --bip)") 61 opts.ListVar(&config.InsecureRegistries, []string{"-insecure-registry"}, "Enable insecure communication with specified registries (no certificate verification for HTTPS and enable HTTP fallback) (e.g., localhost:5000 or 10.20.0.0/16)") 62 flag.BoolVar(&config.InterContainerCommunication, []string{"#icc", "-icc"}, true, "Allow unrestricted inter-container and Docker daemon host communication") 63 flag.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", "Force the Docker runtime to use a specific storage driver") 64 flag.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, "native", "Force the Docker runtime to use a specific exec driver") 65 flag.BoolVar(&config.EnableSelinuxSupport, []string{"-selinux-enabled"}, false, "Enable selinux support. SELinux does not presently support the BTRFS storage driver") 66 flag.IntVar(&config.Mtu, []string{"#mtu", "-mtu"}, 0, "Set the containers network MTU\nif no value is provided: default to the default route MTU or 1500 if no default route is available") 67 opts.IPVar(&config.DefaultIp, []string{"#ip", "-ip"}, "0.0.0.0", "Default IP address to use when binding container ports") 68 opts.ListVar(&config.GraphOptions, []string{"-storage-opt"}, "Set storage driver options") 69 // FIXME: why the inconsistency between "hosts" and "sockets"? 70 opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers") 71 opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains") 72 opts.MirrorListVar(&config.Mirrors, []string{"-registry-mirror"}, "Specify a preferred Docker registry mirror") 73 opts.LabelListVar(&config.Labels, []string{"-label"}, "Set key=value labels to the daemon (displayed in `docker info`)") 74 75 // Localhost is by default considered as an insecure registry 76 // This is a stop-gap for people who are running a private registry on localhost (especially on Boot2docker). 77 // 78 // TODO: should we deprecate this once it is easier for people to set up a TLS registry or change 79 // daemon flags on boot2docker? 80 // If so, do not forget to check the TODO in TestIsSecure 81 config.InsecureRegistries = append(config.InsecureRegistries, "127.0.0.0/8") 82 } 83 84 func getDefaultNetworkMtu() int { 85 if iface, err := networkdriver.GetDefaultRouteIface(); err == nil { 86 return iface.MTU 87 } 88 return defaultNetworkMtu 89 }