Browse code

Merge pull request #6797 from zhgwenming/master

make /.dockerinit bind mount driver specific

Victor Vieux authored on 2014/07/17 08:01:43
Showing 4 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
 	}
... ...
@@ -37,7 +37,7 @@ func TestLXCConfig(t *testing.T) {
37 37
 		cpu    = cpuMin + rand.Intn(cpuMax-cpuMin)
38 38
 	)
39 39
 
40
-	driver, err := NewDriver(root, false)
40
+	driver, err := NewDriver(root, "", false)
41 41
 	if err != nil {
42 42
 		t.Fatal(err)
43 43
 	}
... ...
@@ -73,7 +73,7 @@ func TestCustomLxcConfig(t *testing.T) {
73 73
 
74 74
 	os.MkdirAll(path.Join(root, "containers", "1"), 0777)
75 75
 
76
-	driver, err := NewDriver(root, false)
76
+	driver, err := NewDriver(root, "", false)
77 77
 	if err != nil {
78 78
 		t.Fatal(err)
79 79
 	}
... ...
@@ -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