10BC0 Merge pull request #37665 from kolyshkin/dev-init · moby/moby@7129beb · GitHub
[go: up one dir, main page]

Skip to content

Commit 7129beb

Browse files
authored
Merge pull request #37665 from kolyshkin/dev-init
Fix docker --init with /dev bind mount
2 parents 53e55db + bcacbf5 commit 7129beb

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

daemon/oci_linux.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ import (
2727
"golang.org/x/sys/unix"
2828
)
2929

30+
const (
31+
inContainerInitPath = "/sbin/" + daemonconfig.DefaultInitBinary
32+
)
33+
3034
func setResources(s *specs.Spec, r containertypes.Resources) error {
3135
weightDevices, err := getBlkioWeightDevices(r)
3236
if err != nil {
@@ -657,19 +661,16 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container)
657661
if c.HostConfig.PidMode.IsPrivate() {
658662
if (c.HostConfig.Init != nil && *c.HostConfig.Init) ||
659663
(c.HostConfig.Init == nil && daemon.configStore.Init) {
660-
s.Process.Args = append([]string{"/dev/init", "--", c.Path}, c.Args...)
661-
var path string
662-
if daemon.configStore.InitPath == "" {
664+
s.Process.Args = append([]string{inContainerInitPath, "--", c.Path}, c.Args...)
665+
path := daemon.configStore.InitPath
666+
if path == "" {
663667
path, err = exec.LookPath(daemonconfig.DefaultInitBinary)
664668
if err != nil {
665669
return err
666670
}
667671
}
668-
if daemon.configStore.InitPath != "" {
669-
path = daemon.configStore.InitPath
670-
}
671672
s.Mounts = append(s.Mounts, specs.Mount{
672-
Destination: "/dev/init",
673+
Destination: inContainerInitPath,
673674
Type: "bind",
674675
Source: path,
675676
Options: []string{"bind", "ro"},

0 commit comments

Comments
 (0)
0