8000 configure docker-init binary path · moby/moby@6a12685 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a12685

Browse files
committed
configure docker-init binary path
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent b826beb commit 6a12685

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

api/types/container/host_config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,7 @@ type HostConfig struct {
324324

325325
// Run a custom init inside the container, if null, use the daemon's configured settings
326326
Init *bool `json:",omitempty"`
327+
328+
// Custom init path
329+
InitPath string `json:",omitempty"`
327330
}

daemon/config_unix.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Config struct {
3636
DefaultRuntime string `json:"default-runtime,omitempty"`
3737
OOMScoreAdjust int `json:"oom-score-adjust,omitempty"`
3838
Init bool `json:"init,omitempty"`
39+
InitPath string `json:"init-path,omitempty"`
3940
}
4041

4142
// bridgeConfig stores all the bridge driver specific
@@ -93,6 +94,7 @@ func (config *Config) InstallFlags(flags *pflag.FlagSet) {
9394
flags.StringVar(&config.DefaultRuntime, "default-runtime", stockRuntimeName, "Default OCI runtime for containers")
9495
flags.IntVar(&config.OOMScoreAdjust, "oom-score-adjust", -500, "Set the oom_score_adj for the daemon")
9596
flags.BoolVar(&config.Init, "init", false, "Run an init in the container to forward signals and reap processes")
97+
flags.StringVar(&config.InitPath, "init-path", "", "Path to the docker-init binary")
9698

9799
config.attachExperimentalFlags(flags)
98100
}

daemon/oci_linux.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,18 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container)
594594
if (c.HostConfig.Init != nil && *c.HostConfig.Init) ||
595595
(c.HostConfig.Init == nil && daemon.configStore.Init) {
596596
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
600609
}
601610
s.Mounts = append(s.Mounts, specs.Mount{
602611
Destination: "/dev/init",

docs/reference/commandline/dockerd.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Options:
4949
--help Print usage
5050
--icc=true Enable inter-container communication
5151
--init Run an init inside containers to forward signals and reap processes
52+
--init-path Path to the docker-init binary
5253
--insecure-registry=[] Enable insecure registry communication
5354
--ip=0.0.0.0 Default IP when binding container ports
5455
--ip-forward=true Enable net.ipv4.ip_forward
@@ -1142,6 +1143,7 @@ This is a full example of the allowed configuration options on Linux:
11421143
"cgroup-parent": "",
11431144
"default-ulimits": {},
11441145
"init": false,
1146+
"init-path": "/usr/libexec/docker-init",
11451147
"ipv6": false,
11461148
"iptables": false,
11471149
"ip-forward": false,

man/dockerd.8.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dockerd - Enable daemon mode
3535
[**--help**]
3636
[**--icc**[=*true*]]
3737
[**--init**[=*false*]]
38+
[**--init-path**[=*""*]]
3839
[**--insecure-registry**[=*[]*]]
3940
[**--ip**[=*0.0.0.0*]]
4041
[**--ip-forward**[=*true*]]
@@ -170,6 +171,9 @@ unix://[/path/to/socket] to use.
170171
**--init**
171< 6D40 /td>172
Run an init process inside containers for signal forwarding and process reaping.
172173

174+
**--init-path**
175+
Path to the docker-init binary.
176+
173177
**--insecure-registry**=[]
174178
Enable insecure registry communication, i.e., enable un-encrypted and/or untrusted communication.
175179

runconfig/opts/parse.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ type ContainerOptions struct {
104104
runtime string
105105
autoRemove bool
106106
init bool
107+
initPath string
107108

108109
Image string
109110
Args []string
@@ -246,6 +247,7 @@ func AddFlags(flags *pflag.FlagSet) *ContainerOptions {
246247
flags.StringVar(&copts.runtime, "runtime", "", "Runtime to use for this container")
247248

248249
flags.BoolVar(&copts.init, "init", false, "Run an init inside the container that forwards signals and reaps processes")
250+
flags.StringVar(&copts.initPath, "init-path", "", "Path to the docker-init binary")
249251
return copts
250252
}
251253

0 commit comments

Comments
 (0)
0