2014-10-17 08:00:59 +08:00
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
2014-11-27 02:16:53 +08:00
|
|
|
"syscall"
|
|
|
|
|
2014-12-17 17:12:23 +08:00
|
|
|
"github.com/docker/libcontainer/configs"
|
2014-10-17 08:00:59 +08:00
|
|
|
)
|
|
|
|
|
2015-02-07 11:16:11 +08:00
|
|
|
var standardEnvironment = []string{
|
|
|
|
"HOME=/root",
|
|
|
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
|
|
|
"HOSTNAME=integration",
|
|
|
|
"TERM=xterm",
|
|
|
|
}
|
|
|
|
|
2014-10-17 08:00:59 +08:00
|
|
|
// newTemplateConfig returns a base template for running a container
|
|
|
|
//
|
|
|
|
// it uses a network strategy of just setting a loopback interface
|
|
|
|
// and the default setup for devices
|
2014-12-17 17:12:23 +08:00
|
|
|
func newTemplateConfig(rootfs string) *configs.Config {
|
|
|
|
return &configs.Config{
|
2015-02-04 09:44:58 +08:00
|
|
|
Rootfs: rootfs,
|
2014-10-17 08:00:59 +08:00
|
|
|
Capabilities: []string{
|
|
|
|
"CHOWN",
|
|
|
|
"DAC_OVERRIDE",
|
|
|
|
"FSETID",
|
|
|
|
"FOWNER",
|
|
|
|
"MKNOD",
|
|
|
|
"NET_RAW",
|
|
|
|
"SETGID",
|
|
|
|
"SETUID",
|
|
|
|
"SETFCAP",
|
|
|
|
"SETPCAP",
|
|
|
|
"NET_BIND_SERVICE",
|
|
|
|
"SYS_CHROOT",
|
|
|
|
"KILL",
|
|
|
|
"AUDIT_WRITE",
|
|
|
|
},
|
2015-01-27 20:54:19 +08:00
|
|
|
Namespaces: configs.Namespaces([]configs.Namespace{
|
|
|
|
{Type: configs.NEWNS},
|
|
|
|
{Type: configs.NEWUTS},
|
|
|
|
{Type: configs.NEWIPC},
|
|
|
|
{Type: configs.NEWPID},
|
|
|
|
{Type: configs.NEWNET},
|
|
|
|
}),
|
2015-02-03 18:53:31 +08:00
|
|
|
Cgroups: &configs.Cgroup{
|
2015-01-21 20:24:18 +08:00
|
|
|
Name: "test",
|
2014-10-17 08:00:59 +08:00
|
|
|
Parent: "integration",
|
|
|
|
AllowAllDevices: false,
|
2015-02-03 20:27:21 +08:00
|
|
|
AllowedDevices: configs.DefaultAllowedDevices,
|
2014-10-17 08:00:59 +08:00
|
|
|
},
|
|
|
|
|
2015-02-07 11:16:11 +08:00
|
|
|
Devices: configs.DefaultAutoCreatedDevices,
|
|
|
|
Hostname: "integration",
|
2014-12-17 17:12:23 +08:00
|
|
|
Networks: []*configs.Network{
|
2014-10-17 08:00:59 +08:00
|
|
|
{
|
|
|
|
Type: "loopback",
|
|
|
|
Address: "127.0.0.1/0",
|
|
|
|
Gateway: "localhost",
|
|
|
|
},
|
|
|
|
},
|
2014-12-17 17:12:23 +08:00
|
|
|
Rlimits: []configs.Rlimit{
|
2014-11-27 02:16:53 +08:00
|
|
|
{
|
|
|
|
Type: syscall.RLIMIT_NOFILE,
|
|
|
|
Hard: uint64(1024),
|
|
|
|
Soft: uint64(1024),
|
|
|
|
},
|
|
|
|
},
|
2014-10-17 08:00:59 +08:00
|
|
|
}
|
|
|
|
}
|