2015-04-27 15:20:44 -07:00
|
|
|
// +build linux
|
|
|
|
|
2014-03-05 10:40:55 +01:00
|
|
|
package execdrivers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-01-07 16:22:42 -08:00
|
|
|
"path"
|
|
|
|
|
2015-08-03 09:46:50 -07:00
|
|
|
"github.com/Sirupsen/logrus"
|
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 10:40:55 +01: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-06 11:47:55 -07:00
|
|
|
func NewDriver(name string, options []string, root, libPath, initPath string, sysInfo *sysinfo.SysInfo) (execdriver.Driver, error) {
|
2014-03-05 10:40:55 +01: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 10:40:55 +01:00
|
|
|
// to access and write config and template files in /var/lib/docker/containers/*
|
|
|
|
// to be backwards compatible
|
2015-08-03 09:46:50 -07:00
|
|
|
logrus.Warn("LXC built-in support is deprecated.")
|
2015-03-24 17:11:49 -07:00
|
|
|
return lxc.NewDriver(root, libPath, initPath, sysInfo.AppArmor)
|
2014-03-05 10:40:55 +01:00
|
|
|
case "native":
|
2015-04-06 11:47:55 -07:00
|
|
|
return native.NewDriver(path.Join(root, "execdriver", "native"), initPath, options)
|
2014-03-05 10:40:55 +01:00
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown exec driver %s", name)
|
|
|
|
}
|