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