2014-03-24 03:16:40 -04:00
|
|
|
package template
|
2014-02-21 20:11:57 -05:00
|
|
|
|
|
|
|
import (
|
2015-03-05 12:55:14 -05:00
|
|
|
"syscall"
|
|
|
|
|
2014-06-10 22:58:15 -04:00
|
|
|
"github.com/docker/libcontainer/apparmor"
|
2015-03-05 12:55:14 -05:00
|
|
|
"github.com/docker/libcontainer/configs"
|
2014-02-21 20:11:57 -05:00
|
|
|
)
|
|
|
|
|
2015-03-05 12:55:14 -05:00
|
|
|
const defaultMountFlags = syscall.MS_NOEXEC | syscall.MS_NOSUID | syscall.MS_NODEV
|
|
|
|
|
2014-03-24 03:16:40 -04:00
|
|
|
// New returns the docker default configuration for libcontainer
|
2015-03-05 12:55:14 -05:00
|
|
|
func New() *configs.Config {
|
|
|
|
container := &configs.Config{
|
2014-05-16 20:44:10 -04:00
|
|
|
Capabilities: []string{
|
|
|
|
"CHOWN",
|
|
|
|
"DAC_OVERRIDE",
|
2014-07-10 20:30:56 -04:00
|
|
|
"FSETID",
|
2014-05-19 12:45:52 -04:00
|
|
|
"FOWNER",
|
|
|
|
"MKNOD",
|
|
|
|
"NET_RAW",
|
|
|
|
"SETGID",
|
|
|
|
"SETUID",
|
2014-05-20 03:58:30 -04:00
|
|
|
"SETFCAP",
|
|
|
|
"SETPCAP",
|
|
|
|
"NET_BIND_SERVICE",
|
2014-06-02 21:23:47 -04:00
|
|
|
"SYS_CHROOT",
|
2014-06-07 18:18:18 -04:00
|
|
|
"KILL",
|
2014-07-23 01:57:41 -04:00
|
|
|
"AUDIT_WRITE",
|
2014-02-21 20:11:57 -05:00
|
|
|
},
|
2015-03-05 12:55:14 -05:00
|
|
|
Namespaces: configs.Namespaces([]configs.Namespace{
|
2014-12-23 15:10:03 -05:00
|
|
|
{Type: "NEWNS"},
|
|
|
|
{Type: "NEWUTS"},
|
|
|
|
{Type: "NEWIPC"},
|
|
|
|
{Type: "NEWPID"},
|
|
|
|
{Type: "NEWNET"},
|
2015-01-14 17:01:36 -05:00
|
|
|
}),
|
2015-03-05 12:55:14 -05:00
|
|
|
Cgroups: &configs.Cgroup{
|
2014-02-17 18:14:30 -05:00
|
|
|
Parent: "docker",
|
|
|
|
AllowAllDevices: false,
|
2014-02-21 20:11:57 -05:00
|
|
|
},
|
2015-03-05 12:55:14 -05:00
|
|
|
Mounts: []*configs.Mount{
|
2015-03-19 14:42:23 -04:00
|
|
|
{
|
|
|
|
Source: "proc",
|
|
|
|
Destination: "/proc",
|
|
|
|
Device: "proc",
|
|
|
|
Flags: defaultMountFlags,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "tmpfs",
|
|
|
|
Destination: "/dev",
|
|
|
|
Device: "tmpfs",
|
|
|
|
Flags: syscall.MS_NOSUID | syscall.MS_STRICTATIME,
|
|
|
|
Data: "mode=755",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "devpts",
|
|
|
|
Destination: "/dev/pts",
|
|
|
|
Device: "devpts",
|
|
|
|
Flags: syscall.MS_NOSUID | syscall.MS_NOEXEC,
|
|
|
|
Data: "newinstance,ptmxmode=0666,mode=0620,gid=5",
|
|
|
|
},
|
2015-03-05 12:55:14 -05:00
|
|
|
{
|
|
|
|
Device: "tmpfs",
|
|
|
|
Source: "shm",
|
|
|
|
Destination: "/dev/shm",
|
|
|
|
Data: "mode=1777,size=65536k",
|
|
|
|
Flags: defaultMountFlags,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "mqueue",
|
|
|
|
Destination: "/dev/mqueue",
|
|
|
|
Device: "mqueue",
|
|
|
|
Flags: defaultMountFlags,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Source: "sysfs",
|
|
|
|
Destination: "/sys",
|
|
|
|
Device: "sysfs",
|
|
|
|
Flags: defaultMountFlags | syscall.MS_RDONLY,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
MaskPaths: []string{
|
|
|
|
"/proc/kcore",
|
|
|
|
},
|
|
|
|
ReadonlyPaths: []string{
|
|
|
|
"/proc/sys", "/proc/sysrq-trigger", "/proc/irq", "/proc/bus",
|
|
|
|
},
|
2014-02-21 20:11:57 -05:00
|
|
|
}
|
2014-06-23 19:43:43 -04:00
|
|
|
|
2014-04-09 06:22:17 -04:00
|
|
|
if apparmor.IsEnabled() {
|
2014-06-26 15:23:53 -04:00
|
|
|
container.AppArmorProfile = "docker-default"
|
2014-04-09 06:22:17 -04:00
|
|
|
}
|
2014-06-23 19:43:43 -04:00
|
|
|
|
2014-04-02 09:07:11 -04:00
|
|
|
return container
|
2014-02-21 20:11:57 -05:00
|
|
|
}
|