|
@@ -6,6 +6,7 @@ import (
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
"github.com/docker/docker/pkg/nat"
|
|
"github.com/docker/docker/pkg/nat"
|
|
|
|
+ "github.com/docker/docker/pkg/stringutils"
|
|
"github.com/docker/docker/pkg/ulimit"
|
|
"github.com/docker/docker/pkg/ulimit"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -209,101 +210,47 @@ func NewLxcConfig(values []KeyValuePair) *LxcConfig {
|
|
return &LxcConfig{values}
|
|
return &LxcConfig{values}
|
|
}
|
|
}
|
|
|
|
|
|
-// CapList represents the list of capabilities of the container.
|
|
|
|
-type CapList struct {
|
|
|
|
- caps []string
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MarshalJSON marshals (or serializes) the CapList into JSON.
|
|
|
|
-func (c *CapList) MarshalJSON() ([]byte, error) {
|
|
|
|
- if c == nil {
|
|
|
|
- return []byte{}, nil
|
|
|
|
- }
|
|
|
|
- return json.Marshal(c.Slice())
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// UnmarshalJSON unmarshals (or deserializes) the specified byte slices
|
|
|
|
-// from JSON to a CapList.
|
|
|
|
-func (c *CapList) UnmarshalJSON(b []byte) error {
|
|
|
|
- if len(b) == 0 {
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var caps []string
|
|
|
|
- if err := json.Unmarshal(b, &caps); err != nil {
|
|
|
|
- var s string
|
|
|
|
- if err := json.Unmarshal(b, &s); err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- caps = append(caps, s)
|
|
|
|
- }
|
|
|
|
- c.caps = caps
|
|
|
|
-
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Len returns the number of specific kernel capabilities.
|
|
|
|
-func (c *CapList) Len() int {
|
|
|
|
- if c == nil {
|
|
|
|
- return 0
|
|
|
|
- }
|
|
|
|
- return len(c.caps)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Slice returns the specific capabilities into a slice of KeyValuePair.
|
|
|
|
-func (c *CapList) Slice() []string {
|
|
|
|
- if c == nil {
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
- return c.caps
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// NewCapList creates a CapList from a slice of string.
|
|
|
|
-func NewCapList(caps []string) *CapList {
|
|
|
|
- return &CapList{caps}
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// HostConfig the non-portable Config structure of a container.
|
|
// HostConfig the non-portable Config structure of a container.
|
|
// Here, "non-portable" means "dependent of the host we are running on".
|
|
// Here, "non-portable" means "dependent of the host we are running on".
|
|
// Portable information *should* appear in Config.
|
|
// Portable information *should* appear in Config.
|
|
type HostConfig struct {
|
|
type HostConfig struct {
|
|
- Binds []string // List of volume bindings for this container
|
|
|
|
- ContainerIDFile string // File (path) where the containerId is written
|
|
|
|
- LxcConf *LxcConfig // Additional lxc configuration
|
|
|
|
- Memory int64 // Memory limit (in bytes)
|
|
|
|
- MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap
|
|
|
|
- KernelMemory int64 // Kernel memory limit (in bytes)
|
|
|
|
- CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers)
|
|
|
|
- CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period
|
|
|
|
- CpusetCpus string // CpusetCpus 0-2, 0,1
|
|
|
|
- CpusetMems string // CpusetMems 0-2, 0,1
|
|
|
|
- CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota
|
|
|
|
- BlkioWeight int64 // Block IO weight (relative weight vs. other containers)
|
|
|
|
- OomKillDisable bool // Whether to disable OOM Killer or not
|
|
|
|
- MemorySwappiness *int64 // Tuning container memory swappiness behaviour
|
|
|
|
- Privileged bool // Is the container in privileged mode
|
|
|
|
- PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host
|
|
|
|
- Links []string // List of links (in the name:alias form)
|
|
|
|
- PublishAllPorts bool // Should docker publish all exposed port for the container
|
|
|
|
- DNS []string `json:"Dns"` // List of DNS server to lookup
|
|
|
|
- DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for
|
|
|
|
- ExtraHosts []string // List of extra hosts
|
|
|
|
- VolumesFrom []string // List of volumes to take from other container
|
|
|
|
- Devices []DeviceMapping // List of devices to map inside the container
|
|
|
|
- NetworkMode NetworkMode // Network namespace to use for the container
|
|
|
|
- IpcMode IpcMode // IPC namespace to use for the container
|
|
|
|
- PidMode PidMode // PID namespace to use for the container
|
|
|
|
- UTSMode UTSMode // UTS namespace to use for the container
|
|
|
|
- CapAdd *CapList // List of kernel capabilities to add to the container
|
|
|
|
- CapDrop *CapList // List of kernel capabilities to remove from the container
|
|
|
|
- GroupAdd []string // List of additional groups that the container process will run as
|
|
|
|
- RestartPolicy RestartPolicy // Restart policy to be used for the container
|
|
|
|
- SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux.
|
|
|
|
- ReadonlyRootfs bool // Is the container root filesystem in read-only
|
|
|
|
- Ulimits []*ulimit.Ulimit // List of ulimits to be set in the container
|
|
|
|
- LogConfig LogConfig // Configuration of the logs for this container
|
|
|
|
- CgroupParent string // Parent cgroup.
|
|
|
|
- ConsoleSize [2]int // Initial console size on Windows
|
|
|
|
|
|
+ Binds []string // List of volume bindings for this container
|
|
|
|
+ ContainerIDFile string // File (path) where the containerId is written
|
|
|
|
+ LxcConf *LxcConfig // Additional lxc configuration
|
|
|
|
+ Memory int64 // Memory limit (in bytes)
|
|
|
|
+ MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap
|
|
|
|
+ KernelMemory int64 // Kernel memory limit (in bytes)
|
|
|
|
+ CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers)
|
|
|
|
+ CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period
|
|
|
|
+ CpusetCpus string // CpusetCpus 0-2, 0,1
|
|
|
|
+ CpusetMems string // CpusetMems 0-2, 0,1
|
|
|
|
+ CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota
|
|
|
|
+ BlkioWeight int64 // Block IO weight (relative weight vs. other containers)
|
|
|
|
+ OomKillDisable bool // Whether to disable OOM Killer or not
|
|
|
|
+ MemorySwappiness *int64 // Tuning container memory swappiness behaviour
|
|
|
|
+ Privileged bool // Is the container in privileged mode
|
|
|
|
+ PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host
|
|
|
|
+ Links []string // List of links (in the name:alias form)
|
|
|
|
+ PublishAllPorts bool // Should docker publish all exposed port for the container
|
|
|
|
+ DNS []string `json:"Dns"` // List of DNS server to lookup
|
|
|
|
+ DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for
|
|
|
|
+ ExtraHosts []string // List of extra hosts
|
|
|
|
+ VolumesFrom []string // List of volumes to take from other container
|
|
|
|
+ Devices []DeviceMapping // List of devices to map inside the container
|
|
|
|
+ NetworkMode NetworkMode // Network namespace to use for the container
|
|
|
|
+ IpcMode IpcMode // IPC namespace to use for the container
|
|
|
|
+ PidMode PidMode // PID namespace to use for the container
|
|
|
|
+ UTSMode UTSMode // UTS namespace to use for the container
|
|
|
|
+ CapAdd *stringutils.StrSlice // List of kernel capabilities to add to the container
|
|
|
|
+ CapDrop *stringutils.StrSlice // List of kernel capabilities to remove from the container
|
|
|
|
+ GroupAdd []string // List of additional groups that the container process will run as
|
|
|
|
+ RestartPolicy RestartPolicy // Restart policy to be used for the container
|
|
|
|
+ SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux.
|
|
|
|
+ ReadonlyRootfs bool // Is the container root filesystem in read-only
|
|
|
|
+ Ulimits []*ulimit.Ulimit // List of ulimits to be set in the container
|
|
|
|
+ LogConfig LogConfig // Configuration of the logs for this container
|
|
|
|
+ CgroupParent string // Parent cgroup.
|
|
|
|
+ ConsoleSize [2]int // Initial console size on Windows
|
|
}
|
|
}
|
|
|
|
|
|
// DecodeHostConfig creates a HostConfig based on the specified Reader.
|
|
// DecodeHostConfig creates a HostConfig based on the specified Reader.
|