Browse code

mount of /.dockerinit is not needed for native driver, so move it into lxc driver

Docker-DCO-1.1-Signed-off-by: Albert Zhang <zhgwenming@gmail.com> (github: zhgwenming)

Albert Zhang authored on 2014/06/03 16:46:01
Showing 3 changed files
... ...
@@ -15,7 +15,7 @@ func NewDriver(name, root, initPath string, sysInfo *sysinfo.SysInfo) (execdrive
15 15
 		// we want to give the lxc driver the full docker root because it needs
16 16
 		// to access and write config and template files in /var/lib/docker/containers/*
17 17
 		// to be backwards compatible
18
-		return lxc.NewDriver(root, sysInfo.AppArmor)
18
+		return lxc.NewDriver(root, initPath, sysInfo.AppArmor)
19 19
 	case "native":
20 20
 		return native.NewDriver(path.Join(root, "execdriver", "native"), initPath)
21 21
 	}
... ...
@@ -54,11 +54,12 @@ func init() {
54 54
 
55 55
 type driver struct {
56 56
 	root       string // root path for the driver to use
57
+	initPath   string
57 58
 	apparmor   bool
58 59
 	sharedRoot bool
59 60
 }
60 61
 
61
-func NewDriver(root string, apparmor bool) (*driver, error) {
62
+func NewDriver(root, initPath string, apparmor bool) (*driver, error) {
62 63
 	// setup unconfined symlink
63 64
 	if err := linkLxcStart(root); err != nil {
64 65
 		return nil, err
... ...
@@ -66,6 +67,7 @@ func NewDriver(root string, apparmor bool) (*driver, error) {
66 66
 	return &driver{
67 67
 		apparmor:   apparmor,
68 68
 		root:       root,
69
+		initPath:   initPath,
69 70
 		sharedRoot: rootIsShared(),
70 71
 	}, nil
71 72
 }
... ...
@@ -79,6 +81,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
79 79
 	if err := execdriver.SetTerminal(c, pipes); err != nil {
80 80
 		return -1, err
81 81
 	}
82
+	c.Mounts = append(c.Mounts, execdriver.Mount{d.initPath, c.InitPath, false, true})
82 83
 	if err := d.generateEnvConfig(c); err != nil {
83 84
 		return -1, err
84 85
 	}
... ...
@@ -36,7 +36,6 @@ func prepareVolumesForContainer(container *Container) error {
36 36
 
37 37
 func setupMountsForContainer(container *Container) error {
38 38
 	mounts := []execdriver.Mount{
39
-		{container.daemon.sysInitPath, "/.dockerinit", false, true},
40 39
 		{container.ResolvConfPath, "/etc/resolv.conf", false, true},
41 40
 	}
42 41