2015-04-27 18:20:44 -04:00
|
|
|
// +build linux
|
|
|
|
|
2014-03-05 04:40:55 -05:00
|
|
|
package execdrivers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-01-07 19:22:42 -05:00
|
|
|
"path"
|
|
|
|
|
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
|
|
|
)
|
|
|
|
|
2015-04-06 14:47:55 -04:00
|
|
|
func NewDriver(name string, options []string, root, libPath, 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
|
2015-03-24 20:11:49 -04:00
|
|
|
return lxc.NewDriver(root, libPath, initPath, sysInfo.AppArmor)
|
2014-03-05 04:40:55 -05:00
|
|
|
case "native":
|
2015-04-06 14:47:55 -04:00
|
|
|
return native.NewDriver(path.Join(root, "execdriver", "native"), initPath, options)
|
2014-03-05 04:40:55 -05:00
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown exec driver %s", name)
|
|
|
|
}
|