Browse code

configure docker-init binary path

Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Antonio Murdaca authored on 2016/09/27 19:51:42
Showing 6 changed files
... ...
@@ -324,4 +324,7 @@ type HostConfig struct {
324 324
 
325 325
 	// Run a custom init inside the container, if null, use the daemon's configured settings
326 326
 	Init *bool `json:",omitempty"`
327
+
328
+	// Custom init path
329
+	InitPath string `json:",omitempty"`
327 330
 }
... ...
@@ -36,6 +36,7 @@ type Config struct {
36 36
 	DefaultRuntime       string                   `json:"default-runtime,omitempty"`
37 37
 	OOMScoreAdjust       int                      `json:"oom-score-adjust,omitempty"`
38 38
 	Init                 bool                     `json:"init,omitempty"`
39
+	InitPath             string                   `json:"init-path,omitempty"`
39 40
 }
40 41
 
41 42
 // bridgeConfig stores all the bridge driver specific
... ...
@@ -93,6 +94,7 @@ func (config *Config) InstallFlags(flags *pflag.FlagSet) {
93 93
 	flags.StringVar(&config.DefaultRuntime, "default-runtime", stockRuntimeName, "Default OCI runtime for containers")
94 94
 	flags.IntVar(&config.OOMScoreAdjust, "oom-score-adjust", -500, "Set the oom_score_adj for the daemon")
95 95
 	flags.BoolVar(&config.Init, "init", false, "Run an init in the container to forward signals and reap processes")
96
+	flags.StringVar(&config.InitPath, "init-path", "", "Path to the docker-init binary")
96 97
 
97 98
 	config.attachExperimentalFlags(flags)
98 99
 }
... ...
@@ -594,9 +594,18 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container)
594 594
 		if (c.HostConfig.Init != nil && *c.HostConfig.Init) ||
595 595
 			(c.HostConfig.Init == nil && daemon.configStore.Init) {
596 596
 			s.Process.Args = append([]string{"/dev/init", c.Path}, c.Args...)
597
-			path, err := exec.LookPath("docker-init")
598
-			if err != nil {
599
-				return err
597
+			var path string
598
+			if daemon.configStore.InitPath == "" && c.HostConfig.InitPath == "" {
599
+				path, err = exec.LookPath("docker-init")
600
+				if err != nil {
601
+					return err
602
+				}
603
+			}
604
+			if daemon.configStore.InitPath != "" {
605
+				path = daemon.configStore.InitPath
606
+			}
607
+			if c.HostConfig.InitPath != "" {
608
+				path = c.HostConfig.InitPath
600 609
 			}
601 610
 			s.Mounts = append(s.Mounts, specs.Mount{
602 611
 				Destination: "/dev/init",
... ...
@@ -49,6 +49,7 @@ Options:
49 49
       --help                                 Print usage
50 50
       --icc=true                             Enable inter-container communication
51 51
       --init                                 Run an init inside containers to forward signals and reap processes
52
+      --init-path                            Path to the docker-init binary
52 53
       --insecure-registry=[]                 Enable insecure registry communication
53 54
       --ip=0.0.0.0                           Default IP when binding container ports
54 55
       --ip-forward=true                      Enable net.ipv4.ip_forward
... ...
@@ -1142,6 +1143,7 @@ This is a full example of the allowed configuration options on Linux:
1142 1142
 	"cgroup-parent": "",
1143 1143
 	"default-ulimits": {},
1144 1144
 	"init": false,
1145
+	"init-path": "/usr/libexec/docker-init",
1145 1146
 	"ipv6": false,
1146 1147
 	"iptables": false,
1147 1148
 	"ip-forward": false,
... ...
@@ -35,6 +35,7 @@ dockerd - Enable daemon mode
35 35
 [**--help**]
36 36
 [**--icc**[=*true*]]
37 37
 [**--init**[=*false*]]
38
+[**--init-path**[=*""*]]
38 39
 [**--insecure-registry**[=*[]*]]
39 40
 [**--ip**[=*0.0.0.0*]]
40 41
 [**--ip-forward**[=*true*]]
... ...
@@ -170,6 +171,9 @@ unix://[/path/to/socket] to use.
170 170
 **--init**
171 171
 Run an init process inside containers for signal forwarding and process reaping.
172 172
 
173
+**--init-path**
174
+Path to the docker-init binary.
175
+
173 176
 **--insecure-registry**=[]
174 177
   Enable insecure registry communication, i.e., enable un-encrypted and/or untrusted communication.
175 178
 
... ...
@@ -104,6 +104,7 @@ type ContainerOptions struct {
104 104
 	runtime           string
105 105
 	autoRemove        bool
106 106
 	init              bool
107
+	initPath          string
107 108
 
108 109
 	Image string
109 110
 	Args  []string
... ...
@@ -246,6 +247,7 @@ func AddFlags(flags *pflag.FlagSet) *ContainerOptions {
246 246
 	flags.StringVar(&copts.runtime, "runtime", "", "Runtime to use for this container")
247 247
 
248 248
 	flags.BoolVar(&copts.init, "init", false, "Run an init inside the container that forwards signals and reaps processes")
249
+	flags.StringVar(&copts.initPath, "init-path", "", "Path to the docker-init binary")
249 250
 	return copts
250 251
 }
251 252