Bind mounting alloc dir into container

This commit is contained in:
Diptanu Choudhury
2016-09-15 21:48:59 -07:00
committed by Michael Schurter
parent 9ae6c0e8d4
commit d4fba69b95

View File

@@ -181,6 +181,21 @@ func (d *LxcDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
return nil, fmt.Errorf("error setting network type configuration: %v", err)
}
// Bind mount the shared alloc dir and task local dir in the container
taskLocalDir, ok := ctx.AllocDir.TaskDirs[task.Name]
if !ok {
return nil, fmt.Errorf("failed to find task local directory: %v", task.Name)
}
taskDirMount := fmt.Sprintf("%s local none rw,bind,create=dir", taskLocalDir)
allocDirMount := fmt.Sprintf("%s alloc none rw,bind,create=dir", ctx.AllocDir.SharedDir)
if err := c.SetConfigItem("lxc.mount.entry", allocDirMount); err != nil {
return nil, fmt.Errorf("error setting alloc dir bind mounts configuration: %v", err)
}
if err := c.SetConfigItem("lxc.mount.entry", taskDirMount); err != nil {
return nil, fmt.Errorf("error setting task dir bind mounts configuration: %v", err)
}
if err := c.Start(); err != nil {
return nil, fmt.Errorf("unable to start container: %v", err)
}