mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #37665 from kolyshkin/dev-init
Fix docker --init with /dev bind mount
This commit is contained in:
commit
7129bebe0a
1 changed files with 8 additions and 7 deletions
|
@ -27,6 +27,10 @@ import (
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
inContainerInitPath = "/sbin/" + daemonconfig.DefaultInitBinary
|
||||||
|
)
|
||||||
|
|
||||||
func setResources(s *specs.Spec, r containertypes.Resources) error {
|
func setResources(s *specs.Spec, r containertypes.Resources) error {
|
||||||
weightDevices, err := getBlkioWeightDevices(r)
|
weightDevices, err := getBlkioWeightDevices(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -657,19 +661,16 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container)
|
||||||
if c.HostConfig.PidMode.IsPrivate() {
|
if c.HostConfig.PidMode.IsPrivate() {
|
||||||
if (c.HostConfig.Init != nil && *c.HostConfig.Init) ||
|
if (c.HostConfig.Init != nil && *c.HostConfig.Init) ||
|
||||||
(c.HostConfig.Init == nil && daemon.configStore.Init) {
|
(c.HostConfig.Init == nil && daemon.configStore.Init) {
|
||||||
s.Process.Args = append([]string{"/dev/init", "--", c.Path}, c.Args...)
|
s.Process.Args = append([]string{inContainerInitPath, "--", c.Path}, c.Args...)
|
||||||
var path string
|
path := daemon.configStore.InitPath
|
||||||
if daemon.configStore.InitPath == "" {
|
if path == "" {
|
||||||
path, err = exec.LookPath(daemonconfig.DefaultInitBinary)
|
path, err = exec.LookPath(daemonconfig.DefaultInitBinary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if daemon.configStore.InitPath != "" {
|
|
||||||
path = daemon.configStore.InitPath
|
|
||||||
}
|
|
||||||
s.Mounts = append(s.Mounts, specs.Mount{
|
s.Mounts = append(s.Mounts, specs.Mount{
|
||||||
Destination: "/dev/init",
|
Destination: inContainerInitPath,
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Source: path,
|
Source: path,
|
||||||
Options: []string{"bind", "ro"},
|
Options: []string{"bind", "ro"},
|
||||||
|
|
Loading…
Reference in a new issue