2015-04-28 06:20:44 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
2014-03-05 17:40:55 +08:00
|
|
|
package execdrivers
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2015-01-08 08:22:42 +08:00
|
|
|
"path"
|
|
|
|
|
|
2014-07-25 06:19:50 +08: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 17:40:55 +08:00
|
|
|
)
|
|
|
|
|
|
2015-07-28 08:43:22 +08:00
|
|
|
// NewDriver returns a new execdriver.Driver from the given name configured with the provided options.
|
2015-04-07 02:47:55 +08:00
|
|
|
func NewDriver(name string, options []string, root, libPath, initPath string, sysInfo *sysinfo.SysInfo) (execdriver.Driver, error) {
|
2014-03-05 17:40:55 +08:00
|
|
|
switch name {
|
|
|
|
|
case "lxc":
|
2014-05-16 19:45:20 +08:00
|
|
|
// we want to give the lxc driver the full docker root because it needs
|
2014-03-05 17:40:55 +08:00
|
|
|
// to access and write config and template files in /var/lib/docker/containers/*
|
|
|
|
|
// to be backwards compatible
|
2015-03-25 08:11:49 +08:00
|
|
|
return lxc.NewDriver(root, libPath, initPath, sysInfo.AppArmor)
|
2014-03-05 17:40:55 +08:00
|
|
|
case "native":
|
2015-04-07 02:47:55 +08:00
|
|
|
return native.NewDriver(path.Join(root, "execdriver", "native"), initPath, options)
|
2014-03-05 17:40:55 +08:00
|
|
|
}
|
|
|
|
|
return nil, fmt.Errorf("unknown exec driver %s", name)
|
|
|
|
|
}
|