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{
|
2015-06-18 19:27:04 -04:00
|
|
|
Parent: "docker",
|
|
|
|
AllowAllDevices: false,
|
|
|
|
MemorySwappiness: -1,
|
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,
|
|
|
|
},
|
2015-07-10 01:12:09 -04:00
|
|
|
{
|
|
|
|
Source: "cgroup",
|
|
|
|
Destination: "/sys/fs/cgroup",
|
|
|
|
Device: "cgroup",
|
|
|
|
Flags: defaultMountFlags | syscall.MS_RDONLY,
|
|
|
|
},
|
2015-03-05 12:55:14 -05:00
|
|
|
},
|
|
|
|
MaskPaths: []string{
|
|
|
|
"/proc/kcore",
|
2015-04-29 14:20:31 -04:00
|
|
|
"/proc/latency_stats",
|
|
|
|
"/proc/timer_stats",
|
2015-03-05 12:55:14 -05:00
|
|
|
},
|
|
|
|
ReadonlyPaths: []string{
|
2015-04-20 14:58:24 -04:00
|
|
|
"/proc/asound",
|
|
|
|
"/proc/bus",
|
2015-04-20 16:33:51 -04:00
|
|
|
"/proc/fs",
|
2015-04-20 14:58:24 -04:00
|
|
|
"/proc/irq",
|
|
|
|
"/proc/sys",
|
|
|
|
"/proc/sysrq-trigger",
|
2015-03-05 12:55:14 -05:00
|
|
|
},
|
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
|
|
|
}
|