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