2014-02-19 08:56:11 +08:00
|
|
|
package libcontainer
|
|
|
|
|
2014-02-21 07:48:48 +08:00
|
|
|
import (
|
2014-06-10 23:14:16 +08:00
|
|
|
"github.com/docker/libcontainer/cgroups"
|
2014-06-24 02:41:39 +08:00
|
|
|
"github.com/docker/libcontainer/mount"
|
2014-06-24 05:11:01 +08:00
|
|
|
"github.com/docker/libcontainer/network"
|
2014-02-21 07:48:48 +08:00
|
|
|
)
|
|
|
|
|
2014-06-24 05:11:01 +08:00
|
|
|
type MountConfig mount.MountConfig
|
2014-06-20 07:36:39 +08:00
|
|
|
|
2014-06-24 05:11:01 +08:00
|
|
|
type Network network.Network
|
2014-06-20 07:36:39 +08:00
|
|
|
|
2014-05-21 07:34:46 +08:00
|
|
|
// Container defines configuration options for executing a process inside a contained environment
|
2014-02-19 08:56:11 +08:00
|
|
|
type Container struct {
|
2014-06-24 05:11:01 +08:00
|
|
|
// Mount specific options.
|
|
|
|
MountConfig MountConfig `json:"mount_config,omitempty"`
|
2014-06-20 07:36:39 +08:00
|
|
|
|
|
|
|
// Hostname optionally sets the container's hostname if provided
|
|
|
|
Hostname string `json:"hostname,omitempty"`
|
2014-05-21 07:34:46 +08:00
|
|
|
|
|
|
|
// User will set the uid and gid of the executing process running inside the container
|
|
|
|
User string `json:"user,omitempty"`
|
|
|
|
|
|
|
|
// WorkingDir will change the processes current working directory inside the container's rootfs
|
|
|
|
WorkingDir string `json:"working_dir,omitempty"`
|
|
|
|
|
|
|
|
// Env will populate the processes environment with the provided values
|
|
|
|
// Any values from the parent processes will be cleared before the values
|
|
|
|
// provided in Env are provided to the process
|
|
|
|
Env []string `json:"environment,omitempty"`
|
|
|
|
|
|
|
|
// Tty when true will allocate a pty slave on the host for access by the container's process
|
|
|
|
// and ensure that it is mounted inside the container's rootfs
|
|
|
|
Tty bool `json:"tty,omitempty"`
|
|
|
|
|
|
|
|
// Namespaces specifies the container's namespaces that it should setup when cloning the init process
|
|
|
|
// If a namespace is not provided that namespace is shared from the container's parent process
|
|
|
|
Namespaces map[string]bool `json:"namespaces,omitempty"`
|
|
|
|
|
|
|
|
// Capabilities specify the capabilities to keep when executing the process inside the container
|
|
|
|
// All capbilities not specified will be dropped from the processes capability mask
|
|
|
|
Capabilities []string `json:"capabilities,omitempty"`
|
|
|
|
|
2014-05-21 08:36:50 +08:00
|
|
|
// Networks specifies the container's network setup to be created
|
2014-05-21 07:34:46 +08:00
|
|
|
Networks []*Network `json:"networks,omitempty"`
|
|
|
|
|
2014-05-17 15:06:29 +08:00
|
|
|
// Routes can be specified to create entries in the route table as the container is started
|
|
|
|
Routes []*Route `json:"routes,omitempty"`
|
|
|
|
|
2014-05-21 07:34:46 +08:00
|
|
|
// Cgroups specifies specific cgroup settings for the various subsystems that the container is
|
|
|
|
// placed into to limit the resources the container has available
|
|
|
|
Cgroups *cgroups.Cgroup `json:"cgroups,omitempty"`
|
|
|
|
|
|
|
|
// Context is a generic key value format that allows for additional settings to be passed
|
|
|
|
// on the container's creation
|
|
|
|
// This is commonly used to specify apparmor profiles, selinux labels, and different restrictions
|
|
|
|
// placed on the container's processes
|
2014-06-24 02:54:26 +08:00
|
|
|
// TODO(vishh): Avoid overloading this field with params for different subsystems. Strongtype this.
|
|
|
|
Context map[string]string `json:"context,omitempty"`
|
2014-02-19 08:56:11 +08:00
|
|
|
}
|
2014-05-17 15:06:29 +08:00
|
|
|
|
|
|
|
// Routes can be specified to create entries in the route table as the container is started
|
|
|
|
//
|
|
|
|
// All of destination, source, and gateway should be either IPv4 or IPv6.
|
|
|
|
// One of the three options must be present, and ommitted entries will use their
|
|
|
|
// IP family default for the route table. For IPv4 for example, setting the
|
|
|
|
// gateway to 1.2.3.4 and the interface to eth0 will set up a standard
|
|
|
|
// destination of 0.0.0.0(or *) when viewed in the route table.
|
|
|
|
type Route struct {
|
|
|
|
// Sets the destination and mask, should be a CIDR. Accepts IPv4 and IPv6
|
|
|
|
Destination string `json:"destination,omitempty"`
|
|
|
|
|
|
|
|
// Sets the source and mask, should be a CIDR. Accepts IPv4 and IPv6
|
|
|
|
Source string `json:"source,omitempty"`
|
|
|
|
|
|
|
|
// Sets the gateway. Accepts IPv4 and IPv6
|
|
|
|
Gateway string `json:"gateway,omitempty"`
|
|
|
|
|
|
|
|
// The device to set this route up for, for example: eth0
|
|
|
|
InterfaceName string `json:"interface_name,omitempty"`
|
|
|
|
}
|