|
6 | 6 | "strings" |
7 | 7 |
|
8 | 8 | "github.com/docker/docker/pkg/nat" |
| 9 | + "github.com/docker/docker/pkg/stringutils" |
9 | 10 | "github.com/docker/docker/pkg/ulimit" |
10 | 11 | ) |
11 | 12 |
|
@@ -209,101 +210,47 @@ func NewLxcConfig(values []KeyValuePair) *LxcConfig { |
209 | 210 | return &LxcConfig{values} |
210 | 211 | } |
211 | 212 |
|
212 | | -// CapList represents the list of capabilities of the container. |
213 | | -type CapList struct { |
214 | | - caps []string |
215 | | -} |
216 | | - |
217 | | -// MarshalJSON marshals (or serializes) the CapList into JSON. |
218 | | -func (c *CapList) MarshalJSON() ([]byte, error) { |
219 | | - if c == nil { |
220 | | - return []byte{}, nil |
221 | | - } |
222 | | - return json.Marshal(c.Slice()) |
223 | | -} |
224 | | - |
225 | | -// UnmarshalJSON unmarshals (or deserializes) the specified byte slices |
226 | | -// from JSON to a CapList. |
227 | | -func (c *CapList) UnmarshalJSON(b []byte) error { |
228 | | - if len(b) == 0 { |
229 | | - return nil |
230 | | - } |
231 | | - |
232 | | - var caps []string |
233 | | - if err := json.Unmarshal(b, &caps); err != nil { |
234 | | - var s string |
235 | | - if err := json.Unmarshal(b, &s); err != nil { |
236 | | - return err |
237 | | - } |
238 | | - caps = append(caps, s) |
239 | | - } |
240 | | - c.caps = caps |
241 | | - |
242 | | - return nil |
243 | | -} |
244 | | - |
245 | | -// Len returns the number of specific kernel capabilities. |
246 | | -func (c *CapList) Len() int { |
247 | | - if c == nil { |
248 | | - return 0 |
249 | | - } |
250 | | - return len(c.caps) |
251 | | -} |
252 | | - |
253 | | -// Slice returns the specific capabilities into a slice of KeyValuePair. |
254 | | -func (c *CapList) Slice() []string { |
255 | | - if c == nil { |
256 | | - return nil |
257 | | - } |
258 | | - return c.caps |
259 | | -} |
260 | | - |
261 | | -// NewCapList creates a CapList from a slice of string. |
262 | | -func NewCapList(caps []string) *CapList { |
263 | | - return &CapList{caps} |
264 | | -} |
265 | | - |
266 | 213 | // HostConfig the non-portable Config structure of a container. |
267 | 214 | // Here, "non-portable" means "dependent of the host we are running on". |
268 | 215 | // Portable information *should* appear in Config. |
269 | 216 | type HostConfig struct { |
270 | | - Binds []string // List of volume bindings for this container |
271 | | - ContainerIDFile string // File (path) where the containerId is written |
272 | | - LxcConf *LxcConfig // Additional lxc configuration |
273 | | - Memory int64 // Memory limit (in bytes) |
274 | | - MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap |
275 | | - KernelMemory int64 // Kernel memory limit (in bytes) |
276 | | - CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers) |
277 | | - CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period |
278 | | - CpusetCpus string // CpusetCpus 0-2, 0,1 |
279 | | - CpusetMems string // CpusetMems 0-2, 0,1 |
280 | | - CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota |
281 | | - BlkioWeight int64 // Block IO weight (relative weight vs. other containers) |
282 | | - OomKillDisable bool // Whether to disable OOM Killer or not |
283 | | - MemorySwappiness *int64 // Tuning container memory swappiness behaviour |
284 | | - Privileged bool // Is the container in privileged mode |
285 | | - PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host |
286 | | - Links []string // List of links (in the name:alias form) |
287 | | - PublishAllPorts bool // Should docker publish all exposed port for the container |
288 | | - DNS []string `json:"Dns"` // List of DNS server to lookup |
289 | | - DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for |
290 | | - ExtraHosts []string // List of extra hosts |
291 | | - VolumesFrom []string // List of volumes to take from other container |
292 | | - Devices []DeviceMapping // List of devices to map inside the container |
293 | | - NetworkMode NetworkMode // Network namespace to use for the container |
294 | | - IpcMode IpcMode // IPC namespace to use for the container |
295 | | - PidMode PidMode // PID namespace to use for the container |
296 | | - UTSMode UTSMode // UTS namespace to use for the container |
297 | | - CapAdd *CapList // List of kernel capabilities to add to the container |
298 | | - CapDrop *CapList // List of kernel capabilities to remove from the container |
299 | | - GroupAdd []string // List of additional groups that the container process will run as |
300 | | - RestartPolicy RestartPolicy // Restart policy to be used for the container |
301 | | - SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. |
302 | | - ReadonlyRootfs bool // Is the container root filesystem in read-only |
303 | | - Ulimits []*ulimit.Ulimit // List of ulimits to be set in the container |
304 | | - LogConfig LogConfig // Configuration of the logs for this container |
305 | | - CgroupParent string // Parent cgroup. |
306 | | - ConsoleSize [2]int // Initial console size on Windows |
| 217 | + Binds []string // List of volume bindings for this container |
| 218 | + ContainerIDFile string // File (path) where the containerId is written |
| 219 | + LxcConf *LxcConfig // Additional lxc configuration |
| 220 | + Memory int64 // Memory limit (in bytes) |
| 221 | + MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap |
| 222 | + KernelMemory int64 // Kernel memory limit (in bytes) |
| 223 | + CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers) |
| 224 | + CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period |
| 225 | + CpusetCpus string // CpusetCpus 0-2, 0,1 |
| 226 | + CpusetMems string // CpusetMems 0-2, 0,1 |
| 227 | + CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota |
| 228 | + BlkioWeight int64 // Block IO weight (relative weight vs. other containers) |
| 229 | + OomKillDisable bool // Whether to disable OOM Killer or not |
| 230 | + MemorySwappiness *int64 // Tuning container memory swappiness behaviour |
| 231 | + Privileged bool // Is the container in privileged mode |
| 232 | + PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host |
| 233 | + Links []string // List of links (in the name:alias form) |
| 234 | + PublishAllPorts bool // Should docker publish all exposed port for the container |
| 235 | + DNS []string `json:"Dns"` // List of DNS server to lookup |
| 236 | + DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for |
| 237 | + ExtraHosts []string // List of extra hosts |
| 238 | + VolumesFrom []string // List of volumes to take from other container |
| 239 | + Devices []DeviceMapping // List of devices to map inside the container |
| 240 | + NetworkMode NetworkMode // Network namespace to use for the container |
| 241 | + IpcMode IpcMode // IPC namespace to use for the container |
| 242 | + PidMode PidMode // PID namespace to use for the container |
| 243 | + UTSMode UTSMode // UTS namespace to use for the container |
| 244 | + CapAdd *stringutils.StrSlice // List of kernel capabilities to add to the container |
| 245 | + CapDrop *stringutils.StrSlice // List of kernel capabilities to remove from the container |
| 246 | + GroupAdd []string // List of additional groups that the container process will run as |
| 247 | + RestartPolicy RestartPolicy // Restart policy to be used for the container |
| 248 | + SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. |
| 249 | + ReadonlyRootfs bool // Is the container root filesystem in read-only |
| 250 | + Ulimits []*ulimit.Ulimit // List of ulimits to be set in the container |
| 251 | + LogConfig LogConfig // Configuration of the logs for this container |
| 252 | + CgroupParent string // Parent cgroup. |
| 253 | + ConsoleSize [2]int // Initial console size on Windows |
307 | 254 | } |
308 | 255 |
|
309 | 256 | // DecodeHostConfig creates a HostConfig based on the specified Reader. |
|
0 commit comments