container.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package libcontainer
  2. import (
  3. "github.com/dotcloud/docker/pkg/libcontainer/cgroups"
  4. )
  5. // Context is a generic key value pair that allows arbatrary data to be sent
  6. type Context map[string]string
  7. // Container defines configuration options for executing a process inside a contained environment
  8. type Container struct {
  9. // Hostname optionally sets the container's hostname if provided
  10. Hostname string `json:"hostname,omitempty"`
  11. // ReadonlyFs will remount the container's rootfs as readonly where only externally mounted
  12. // bind mounts are writtable
  13. ReadonlyFs bool `json:"readonly_fs,omitempty"`
  14. // NoPivotRoot will use MS_MOVE and a chroot to jail the process into the container's rootfs
  15. // This is a common option when the container is running in ramdisk
  16. NoPivotRoot bool `json:"no_pivot_root,omitempty"`
  17. // User will set the uid and gid of the executing process running inside the container
  18. User string `json:"user,omitempty"`
  19. // WorkingDir will change the processes current working directory inside the container's rootfs
  20. WorkingDir string `json:"working_dir,omitempty"`
  21. // Env will populate the processes environment with the provided values
  22. // Any values from the parent processes will be cleared before the values
  23. // provided in Env are provided to the process
  24. Env []string `json:"environment,omitempty"`
  25. // Tty when true will allocate a pty slave on the host for access by the container's process
  26. // and ensure that it is mounted inside the container's rootfs
  27. Tty bool `json:"tty,omitempty"`
  28. // Namespaces specifies the container's namespaces that it should setup when cloning the init process
  29. // If a namespace is not provided that namespace is shared from the container's parent process
  30. Namespaces map[string]bool `json:"namespaces,omitempty"`
  31. // Capabilities specify the capabilities to keep when executing the process inside the container
  32. // All capbilities not specified will be dropped from the processes capability mask
  33. Capabilities []string `json:"capabilities,omitempty"`
  34. // Networks specifies the container's network setup to be created
  35. Networks []*Network `json:"networks,omitempty"`
  36. // Cgroups specifies specific cgroup settings for the various subsystems that the container is
  37. // placed into to limit the resources the container has available
  38. Cgroups *cgroups.Cgroup `json:"cgroups,omitempty"`
  39. // Context is a generic key value format that allows for additional settings to be passed
  40. // on the container's creation
  41. // This is commonly used to specify apparmor profiles, selinux labels, and different restrictions
  42. // placed on the container's processes
  43. Context Context `json:"context,omitempty"`
  44. // Mounts specify additional source and destination paths that will be mounted inside the container's
  45. // rootfs and mount namespace if specified
  46. Mounts Mounts `json:"mounts,omitempty"`
  47. // RequiredDeviceNodes are a list of device nodes that will be mknod into the container's rootfs at /dev
  48. // If the host system does not support the device that the container requests an error is returned
  49. RequiredDeviceNodes []string `json:"required_device_nodes,omitempty"`
  50. // OptionalDeviceNodes are a list of device nodes that will be mknod into the container's rootfs at /dev
  51. // If the host system does not support the device that the container requests the error is ignored
  52. OptionalDeviceNodes []string `json:"optional_device_nodes,omitempty"`
  53. }
  54. // Network defines configuration for a container's networking stack
  55. //
  56. // The network configuration can be omited from a container causing the
  57. // container to be setup with the host's networking stack
  58. type Network struct {
  59. // Type sets the networks type, commonly veth and loopback
  60. Type string `json:"type,omitempty"`
  61. // Context is a generic key value format for setting additional options that are specific to
  62. // the network type
  63. Context Context `json:"context,omitempty"`
  64. // Address contains the IP and mask to set on the network interface
  65. Address string `json:"address,omitempty"`
  66. // Gateway sets the gateway address that is used as the default for the interface
  67. Gateway string `json:"gateway,omitempty"`
  68. // Mtu sets the mtu value for the interface and will be mirrored on both the host and
  69. // container's interfaces if a pair is created, specifically in the case of type veth
  70. Mtu int `json:"mtu,omitempty"`
  71. }