2014-03-05 04:40:55 -05:00
|
|
|
package execdrivers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-07-24 18:19:50 -04:00
|
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
|
|
"github.com/docker/docker/daemon/execdriver/lxc"
|
|
|
|
"github.com/docker/docker/daemon/execdriver/native"
|
|
|
|
"github.com/docker/docker/pkg/sysinfo"
|
2014-03-05 04:40:55 -05:00
|
|
|
"path"
|
|
|
|
)
|
|
|
|
|
2014-03-03 10:15:29 -05:00
|
|
|
func NewDriver(name, root, initPath string, sysInfo *sysinfo.SysInfo) (execdriver.Driver, error) {
|
2014-03-05 04:40:55 -05:00
|
|
|
switch name {
|
|
|
|
case "lxc":
|
2014-05-16 07:45:20 -04:00
|
|
|
// we want to give the lxc driver the full docker root because it needs
|
2014-03-05 04:40:55 -05:00
|
|
|
// to access and write config and template files in /var/lib/docker/containers/*
|
|
|
|
// to be backwards compatible
|
2014-06-03 03:46:01 -04:00
|
|
|
return lxc.NewDriver(root, initPath, sysInfo.AppArmor)
|
2014-03-05 04:40:55 -05:00
|
|
|
case "native":
|
2014-03-03 10:15:29 -05:00
|
|
|
return native.NewDriver(path.Join(root, "execdriver", "native"), initPath)
|
2014-03-05 04:40:55 -05:00
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown exec driver %s", name)
|
|
|
|
}
|