Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -5,7 +5,6 @@ import ( |
| 5 | 5 |
"github.com/docker/docker/daemon/networkdriver/bridge" |
| 6 | 6 |
"github.com/docker/docker/opts" |
| 7 | 7 |
flag "github.com/docker/docker/pkg/mflag" |
| 8 |
- "github.com/docker/docker/pkg/ulimit" |
|
| 9 | 8 |
"github.com/docker/docker/runconfig" |
| 10 | 9 |
) |
| 11 | 10 |
|
| ... | ... |
@@ -14,42 +13,34 @@ const ( |
| 14 | 14 |
disableNetworkBridge = "none" |
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 |
-// Config define the configuration of a docker daemon |
|
| 18 |
-// These are the configuration settings that you pass |
|
| 19 |
-// to the docker daemon when you launch it with say: `docker -d -e lxc` |
|
| 20 |
-// FIXME: separate runtime configuration from http api configuration |
|
| 21 |
-type Config struct {
|
|
| 22 |
- Bridge bridge.Config |
|
| 23 |
- |
|
| 24 |
- Pidfile string |
|
| 25 |
- Root string |
|
| 26 |
- AutoRestart bool |
|
| 27 |
- Dns []string |
|
| 28 |
- DnsSearch []string |
|
| 29 |
- GraphDriver string |
|
| 30 |
- GraphOptions []string |
|
| 31 |
- ExecDriver string |
|
| 32 |
- ExecOptions []string |
|
| 33 |
- Mtu int |
|
| 34 |
- SocketGroup string |
|
| 35 |
- EnableCors bool |
|
| 36 |
- CorsHeaders string |
|
| 37 |
- DisableNetwork bool |
|
| 38 |
- EnableSelinuxSupport bool |
|
| 39 |
- Context map[string][]string |
|
| 40 |
- TrustKeyPath string |
|
| 41 |
- Labels []string |
|
| 42 |
- Ulimits map[string]*ulimit.Ulimit |
|
| 43 |
- LogConfig runconfig.LogConfig |
|
| 17 |
+// CommonConfig defines the configuration of a docker daemon which are |
|
| 18 |
+// common across platforms. |
|
| 19 |
+type CommonConfig struct {
|
|
| 20 |
+ AutoRestart bool |
|
| 21 |
+ Bridge bridge.Config |
|
| 22 |
+ Context map[string][]string |
|
| 23 |
+ CorsHeaders string |
|
| 24 |
+ DisableNetwork bool |
|
| 25 |
+ Dns []string |
|
| 26 |
+ DnsSearch []string |
|
| 27 |
+ EnableCors bool |
|
| 28 |
+ ExecDriver string |
|
| 29 |
+ GraphDriver string |
|
| 30 |
+ Labels []string |
|
| 31 |
+ LogConfig runconfig.LogConfig |
|
| 32 |
+ Mtu int |
|
| 33 |
+ Pidfile string |
|
| 34 |
+ Root string |
|
| 35 |
+ TrustKeyPath string |
|
| 44 | 36 |
} |
| 45 | 37 |
|
| 46 |
-// InstallFlags adds command-line options to the top-level flag parser for |
|
| 38 |
+// InstallCommonFlags adds command-line options to the top-level flag parser for |
|
| 47 | 39 |
// the current process. |
| 48 | 40 |
// Subsequent calls to `flag.Parse` will populate config with values parsed |
| 49 | 41 |
// from the command-line. |
| 50 |
-func (config *Config) InstallFlags() {
|
|
| 51 |
- flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file")
|
|
| 52 |
- flag.StringVar(&config.Root, []string{"g", "-graph"}, "/var/lib/docker", "Root of the Docker runtime")
|
|
| 42 |
+func (config *Config) InstallCommonFlags() {
|
|
| 43 |
+ flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, defaultPidFile, "Path to use for daemon PID file")
|
|
| 44 |
+ flag.StringVar(&config.Root, []string{"g", "-graph"}, defaultGraph, "Root of the Docker runtime")
|
|
| 53 | 45 |
flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
|
| 54 | 46 |
flag.BoolVar(&config.Bridge.EnableIptables, []string{"#iptables", "-iptables"}, true, "Enable addition of iptables rules")
|
| 55 | 47 |
flag.BoolVar(&config.Bridge.EnableIpForward, []string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward")
|
| ... | ... |
@@ -64,23 +55,18 @@ func (config *Config) InstallFlags() {
|
| 64 | 64 |
flag.BoolVar(&config.Bridge.InterContainerCommunication, []string{"#icc", "-icc"}, true, "Enable inter-container communication")
|
| 65 | 65 |
flag.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", "Storage driver to use")
|
| 66 | 66 |
flag.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, "native", "Exec driver to use")
|
| 67 |
- flag.BoolVar(&config.EnableSelinuxSupport, []string{"-selinux-enabled"}, false, "Enable selinux support")
|
|
| 68 | 67 |
flag.IntVar(&config.Mtu, []string{"#mtu", "-mtu"}, 0, "Set the containers network MTU")
|
| 69 |
- flag.StringVar(&config.SocketGroup, []string{"G", "-group"}, "docker", "Group for the unix socket")
|
|
| 70 | 68 |
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")
|
| 71 | 69 |
flag.StringVar(&config.CorsHeaders, []string{"-api-cors-header"}, "", "Set CORS headers in the remote API")
|
| 72 | 70 |
opts.IPVar(&config.Bridge.DefaultIp, []string{"#ip", "-ip"}, "0.0.0.0", "Default IP when binding container ports")
|
| 73 |
- opts.ListVar(&config.GraphOptions, []string{"-storage-opt"}, "Set storage driver options")
|
|
| 74 |
- opts.ListVar(&config.ExecOptions, []string{"-exec-opt"}, "Set exec driver options")
|
|
| 75 | 71 |
// FIXME: why the inconsistency between "hosts" and "sockets"? |
| 76 | 72 |
opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "DNS server to use")
|
| 77 | 73 |
opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "DNS search domains to use")
|
| 78 | 74 |
opts.LabelListVar(&config.Labels, []string{"-label"}, "Set key=value labels to the daemon")
|
| 79 |
- config.Ulimits = make(map[string]*ulimit.Ulimit) |
|
| 80 |
- opts.UlimitMapVar(config.Ulimits, []string{"-default-ulimit"}, "Set default ulimits for containers")
|
|
| 81 | 75 |
flag.StringVar(&config.LogConfig.Type, []string{"-log-driver"}, "json-file", "Default driver for container logs")
|
| 82 |
- flag.BoolVar(&config.Bridge.EnableUserlandProxy, []string{"-userland-proxy"}, true, "Use userland proxy for loopback traffic")
|
|
| 83 | 76 |
opts.LogOptsVar(config.LogConfig.Config, []string{"-log-opt"}, "Set log driver options")
|
| 77 |
+ flag.BoolVar(&config.Bridge.EnableUserlandProxy, []string{"-userland-proxy"}, true, "Use userland proxy for loopback traffic")
|
|
| 78 |
+ |
|
| 84 | 79 |
} |
| 85 | 80 |
|
| 86 | 81 |
func getDefaultNetworkMtu() int {
|
| 87 | 82 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,43 @@ |
| 0 |
+package daemon |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "github.com/docker/docker/opts" |
|
| 4 |
+ flag "github.com/docker/docker/pkg/mflag" |
|
| 5 |
+ "github.com/docker/docker/pkg/ulimit" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+var ( |
|
| 9 |
+ defaultPidFile = "/var/run/docker.pid" |
|
| 10 |
+ defaultGraph = "/var/lib/docker" |
|
| 11 |
+) |
|
| 12 |
+ |
|
| 13 |
+// Config defines the configuration of a docker daemon. |
|
| 14 |
+// These are the configuration settings that you pass |
|
| 15 |
+// to the docker daemon when you launch it with say: `docker -d -e lxc` |
|
| 16 |
+type Config struct {
|
|
| 17 |
+ CommonConfig |
|
| 18 |
+ |
|
| 19 |
+ // Fields below here are platform specific. |
|
| 20 |
+ EnableSelinuxSupport bool |
|
| 21 |
+ ExecOptions []string |
|
| 22 |
+ GraphOptions []string |
|
| 23 |
+ SocketGroup string |
|
| 24 |
+ Ulimits map[string]*ulimit.Ulimit |
|
| 25 |
+} |
|
| 26 |
+ |
|
| 27 |
+// InstallFlags adds command-line options to the top-level flag parser for |
|
| 28 |
+// the current process. |
|
| 29 |
+// Subsequent calls to `flag.Parse` will populate config with values parsed |
|
| 30 |
+// from the command-line. |
|
| 31 |
+func (config *Config) InstallFlags() {
|
|
| 32 |
+ // First handle install flags which are consistent cross-platform |
|
| 33 |
+ config.InstallCommonFlags() |
|
| 34 |
+ |
|
| 35 |
+ // Then platform-specific install flags |
|
| 36 |
+ opts.ListVar(&config.GraphOptions, []string{"-storage-opt"}, "Set storage driver options")
|
|
| 37 |
+ opts.ListVar(&config.ExecOptions, []string{"-exec-opt"}, "Set exec driver options")
|
|
| 38 |
+ flag.BoolVar(&config.EnableSelinuxSupport, []string{"-selinux-enabled"}, false, "Enable selinux support")
|
|
| 39 |
+ flag.StringVar(&config.SocketGroup, []string{"G", "-group"}, "docker", "Group for the unix socket")
|
|
| 40 |
+ config.Ulimits = make(map[string]*ulimit.Ulimit) |
|
| 41 |
+ opts.UlimitMapVar(config.Ulimits, []string{"-default-ulimit"}, "Set default ulimits for containers")
|
|
| 42 |
+} |
| 0 | 43 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,34 @@ |
| 0 |
+package daemon |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "os" |
|
| 4 |
+ |
|
| 5 |
+ flag "github.com/docker/docker/pkg/mflag" |
|
| 6 |
+) |
|
| 7 |
+ |
|
| 8 |
+var ( |
|
| 9 |
+ defaultPidFile = os.Getenv("programdata") + string(os.PathSeparator) + "docker.pid"
|
|
| 10 |
+ defaultGraph = os.Getenv("programdata") + string(os.PathSeparator) + "docker"
|
|
| 11 |
+) |
|
| 12 |
+ |
|
| 13 |
+// Config defines the configuration of a docker daemon. |
|
| 14 |
+// These are the configuration settings that you pass |
|
| 15 |
+// to the docker daemon when you launch it with say: `docker -d -e windows` |
|
| 16 |
+type Config struct {
|
|
| 17 |
+ CommonConfig |
|
| 18 |
+ |
|
| 19 |
+ // Fields below here are platform specific. (There are none presently |
|
| 20 |
+ // for the Windows daemon.) |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+// InstallFlags adds command-line options to the top-level flag parser for |
|
| 24 |
+// the current process. |
|
| 25 |
+// Subsequent calls to `flag.Parse` will populate config with values parsed |
|
| 26 |
+// from the command-line. |
|
| 27 |
+func (config *Config) InstallFlags() {
|
|
| 28 |
+ // First handle install flags which are consistent cross-platform |
|
| 29 |
+ config.InstallCommonFlags() |
|
| 30 |
+ |
|
| 31 |
+ // Then platform-specific install flags. There are none presently on Windows |
|
| 32 |
+ |
|
| 33 |
+} |