From ad5052df234e4f48a93e22694f91fda36bb9e95d Mon Sep 17 00:00:00 2001 From: John Howard Date: Sat, 31 Oct 2015 18:40:39 -0700 Subject: [PATCH] Tidy config/hostconfig structures Signed-off-by: John Howard --- image/fixtures/pre1.9/expected_computed_id | 2 +- image/fixtures/pre1.9/expected_config | 3 +- runconfig/config.go | 32 ++++++----- runconfig/hostconfig.go | 65 ++++++++++++---------- 4 files changed, 55 insertions(+), 47 deletions(-) diff --git a/image/fixtures/pre1.9/expected_computed_id b/image/fixtures/pre1.9/expected_computed_id index c27b0b6a20..98a34f8c4c 100644 --- a/image/fixtures/pre1.9/expected_computed_id +++ b/image/fixtures/pre1.9/expected_computed_id @@ -1 +1 @@ -sha256:fd6ebfedda8ea140a9380767e15bd32c6e899303cfe34bc4580c931f2f816f89 +sha256:731d62ca192955d38edd4333c89aad021002b1e570daa6bb9f8f06b500c76a4d diff --git a/image/fixtures/pre1.9/expected_config b/image/fixtures/pre1.9/expected_config index 121efe1fe6..e29c9d349f 100644 --- a/image/fixtures/pre1.9/expected_config +++ b/image/fixtures/pre1.9/expected_config @@ -1,2 +1 @@ -{"architecture":"amd64","config":{"Hostname":"03797203757d","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/go/bin:/usr/src/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","GOLANG_VERSION=1.4.1","GOPATH=/go"],"Cmd":null,"Image":"ec3025ca8cc9bcab039e193e20ec647c2da3c53a74020f2ba611601f9b2c6c02","Volumes":null,"WorkingDir":"/go","Entrypoint":["/go/bin/dnsdock"],"OnBuild":[],"Labels":{}},"container":"d91be3479d5b1e84b0c00d18eea9dc777ca0ad166d51174b24283e2e6f104253","container_config":{"Hostname":"03797203757d","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/go/bin:/usr/src/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","GOLANG_VERSION=1.4.1","GOPATH=/go"],"Cmd":["/bin/sh","-c","#(nop) ENTRYPOINT [\"/go/bin/dnsdock\"]"],"Image":"ec3025ca8cc9bcab039e193e20ec647c2da3c53a74020f2ba611601f9b2c6c02","Volumes":null,"WorkingDir":"/go","Entrypoint":["/go/bin/dnsdock"],"OnBuild":[],"Labels":{}},"created":"2015-08-19T16:49:11.368300679Z","docker_version":"1.6.2","layer_id":"sha256:31176893850e05d308cdbfef88877e460d50c8063883fb13eb5753097da6422a","os":"linux","parent_id":"sha256:ec3025ca8cc9bcab039e193e20ec647c2da3c53a74020f2ba611601f9b2c6c02"} - +{"architecture":"amd64","config":{"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Cmd":null,"Entrypoint":["/go/bin/dnsdock"],"Env":["PATH=/go/bin:/usr/src/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","GOLANG_VERSION=1.4.1","GOPATH=/go"],"Hostname":"03797203757d","Image":"ec3025ca8cc9bcab039e193e20ec647c2da3c53a74020f2ba611601f9b2c6c02","Labels":{},"OnBuild":[],"OpenStdin":false,"StdinOnce":false,"Tty":false,"Volumes":null,"WorkingDir":"/go","Domainname":"","User":""},"container":"d91be3479d5b1e84b0c00d18eea9dc777ca0ad166d51174b24283e2e6f104253","container_config":{"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Cmd":["/bin/sh","-c","#(nop) ENTRYPOINT [\"/go/bin/dnsdock\"]"],"Entrypoint":["/go/bin/dnsdock"],"Env":["PATH=/go/bin:/usr/src/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","GOLANG_VERSION=1.4.1","GOPATH=/go"],"Hostname":"03797203757d","Image":"ec3025ca8cc9bcab039e193e20ec647c2da3c53a74020f2ba611601f9b2c6c02","Labels":{},"OnBuild":[],"OpenStdin":false,"StdinOnce":false,"Tty":false,"Volumes":null,"WorkingDir":"/go","Domainname":"","User":""},"created":"2015-08-19T16:49:11.368300679Z","docker_version":"1.6.2","layer_id":"sha256:31176893850e05d308cdbfef88877e460d50c8063883fb13eb5753097da6422a","os":"linux","parent_id":"sha256:ec3025ca8cc9bcab039e193e20ec647c2da3c53a74020f2ba611601f9b2c6c02"} diff --git a/runconfig/config.go b/runconfig/config.go index 47e895871e..93ddb46cb5 100644 --- a/runconfig/config.go +++ b/runconfig/config.go @@ -17,28 +17,32 @@ import ( // All fields added to this struct must be marked `omitempty` to keep getting // predictable hashes from the old `v1Compatibility` configuration. type Config struct { - Hostname string // Hostname - Domainname string // Domainname - User string // User that will run the command(s) inside the container + + // Applicable to all platforms AttachStdin bool // Attach the standard input, makes possible user interaction AttachStdout bool // Attach the standard output AttachStderr bool // Attach the standard error + Cmd *stringutils.StrSlice // Command to run when starting the container + Entrypoint *stringutils.StrSlice // Entrypoint to run when starting the container + Env []string // List of environment variable to set in the container ExposedPorts map[nat.Port]struct{} `json:",omitempty"` // List of exposed ports - PublishService string `json:",omitempty"` // Name of the network service exposed by the container - Tty bool // Attach standard streams to a tty, including stdin if it is not closed. + Hostname string // Hostname + Image string // Name of the image as it was passed by the operator (eg. could be symbolic) + Labels map[string]string // List of labels set to this container + MacAddress string `json:",omitempty"` // Mac Address of the container + NetworkDisabled bool `json:",omitempty"` // Is network disabled (--net=none) + OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile OpenStdin bool // Open stdin StdinOnce bool // If true, close stdin after the 1 attached client disconnects. - Env []string // List of environment variable to set in the container - Cmd *stringutils.StrSlice // Command to run when starting the container - Image string // Name of the image as it was passed by the operator (eg. could be symbolic) + Tty bool // Attach standard streams to a tty, including stdin if it is not closed. Volumes map[string]struct{} // List of volumes (mounts) used for the container WorkingDir string // Current directory (PWD) in the command will be launched - Entrypoint *stringutils.StrSlice // Entrypoint to run when starting the container - NetworkDisabled bool `json:",omitempty"` // Is network disabled - MacAddress string `json:",omitempty"` // Mac Address of the container - OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile - Labels map[string]string // List of labels set to this container - StopSignal string `json:",omitempty"` // Signal to stop a container + + // Applicable to UNIX platforms + Domainname string // Domainname + PublishService string `json:",omitempty"` // Name of the network service exposed by the container + StopSignal string `json:",omitempty"` // Signal to stop a container + User string // User that will run the command(s) inside the container } // DecodeContainerConfig decodes a json encoded config into a ContainerConfigWrapper diff --git a/runconfig/hostconfig.go b/runconfig/hostconfig.go index b48166e598..dae899c4e8 100644 --- a/runconfig/hostconfig.go +++ b/runconfig/hostconfig.go @@ -168,46 +168,51 @@ type LogConfig struct { // Here, "non-portable" means "dependent of the host we are running on". // Portable information *should* appear in Config. type HostConfig struct { - Binds []string // List of volume bindings for this container - ContainerIDFile string // File (path) where the containerId is written - Memory int64 // Memory limit (in bytes) - MemoryReservation int64 // Memory soft 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) + // Applicable to all platforms + Binds []string // List of volume bindings for this container + ContainerIDFile string // File (path) where the containerId is written + CPUShares int64 `json:"CpuShares"` // CPU shares (relative weight vs. other containers) + LogConfig LogConfig // Configuration of the logs for this container + NetworkMode NetworkMode // Network mode to use for the container + PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host + RestartPolicy RestartPolicy // Restart policy to be used for the container + VolumeDriver string // Name of the volume driver used to mount volumes + VolumesFrom []string // List of volumes to take from other container + + // Applicable to UNIX platforms + BlkioWeight uint16 // Block IO weight (relative weight vs. other containers) + CapAdd *stringutils.StrSlice // List of kernel capabilities to add to the container + CapDrop *stringutils.StrSlice // List of kernel capabilities to remove from the container + CgroupParent string // Parent cgroup. CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period + CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota 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 uint16 // 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 + Devices []DeviceMapping // List of devices to map inside the container DNS []string `json:"Dns"` // List of DNS server to lookup DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for 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 // Unix specific - PidMode PidMode // PID namespace to use for the container // Unix specific - UTSMode UTSMode // UTS namespace to use for the container // Unix specific - 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 + IpcMode IpcMode // IPC namespace to use for the container + KernelMemory int64 // Kernel memory limit (in bytes) + Links []string // List of links (in the name:alias form) + Memory int64 // Memory limit (in bytes) + MemoryReservation int64 // Memory soft limit (in bytes) + MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap + MemorySwappiness *int64 // Tuning container memory swappiness behaviour + OomKillDisable bool // Whether to disable OOM Killer or not + PidMode PidMode // PID namespace to use for the container + Privileged bool // Is the container in privileged mode + PublishAllPorts bool // Should docker publish all exposed port for the container + ReadonlyRootfs bool // Is the container root filesystem in read-only 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 // Unix specific 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 - VolumeDriver string // Name of the volume driver used to mount volumes - Isolation IsolationLevel // Isolation level of the container (eg default, hyperv) + UTSMode UTSMode // UTS namespace to use for the container + + // Applicable to Windows + ConsoleSize [2]int // Initial console size + Isolation IsolationLevel // Isolation level of the container (eg default, hyperv) } // DecodeHostConfig creates a HostConfig based on the specified Reader.