default_template.go 931 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package template
  2. import (
  3. "github.com/docker/libcontainer"
  4. "github.com/docker/libcontainer/apparmor"
  5. "github.com/docker/libcontainer/cgroups"
  6. )
  7. // New returns the docker default configuration for libcontainer
  8. func New() *libcontainer.Config {
  9. container := &libcontainer.Config{
  10. Capabilities: []string{
  11. "CHOWN",
  12. "DAC_OVERRIDE",
  13. "FSETID",
  14. "FOWNER",
  15. "MKNOD",
  16. "NET_RAW",
  17. "SETGID",
  18. "SETUID",
  19. "SETFCAP",
  20. "SETPCAP",
  21. "NET_BIND_SERVICE",
  22. "SYS_CHROOT",
  23. "KILL",
  24. "AUDIT_WRITE",
  25. },
  26. Namespaces: libcontainer.Namespaces([]libcontainer.Namespace{
  27. {Type: "NEWNS"},
  28. {Type: "NEWUTS"},
  29. {Type: "NEWIPC"},
  30. {Type: "NEWPID"},
  31. {Type: "NEWNET"},
  32. }),
  33. Cgroups: &cgroups.Cgroup{
  34. Parent: "docker",
  35. AllowAllDevices: false,
  36. },
  37. MountConfig: &libcontainer.MountConfig{},
  38. }
  39. if apparmor.IsEnabled() {
  40. container.AppArmorProfile = "docker-default"
  41. }
  42. return container
  43. }