github.com/lmars/docker@v1.6.0-rc2/runconfig/config.go (about) 1 package runconfig 2 3 import ( 4 "github.com/docker/docker/engine" 5 "github.com/docker/docker/nat" 6 ) 7 8 // Note: the Config structure should hold only portable information about the container. 9 // Here, "portable" means "independent from the host we are running on". 10 // Non-portable information *should* appear in HostConfig. 11 type Config struct { 12 Hostname string 13 Domainname string 14 User string 15 Memory int64 // FIXME: we keep it for backward compatibility, it has been moved to hostConfig. 16 MemorySwap int64 // FIXME: it has been moved to hostConfig. 17 CpuShares int64 // FIXME: it has been moved to hostConfig. 18 Cpuset string // FIXME: it has been moved to hostConfig and renamed to CpusetCpus. 19 AttachStdin bool 20 AttachStdout bool 21 AttachStderr bool 22 PortSpecs []string // Deprecated - Can be in the format of 8080/tcp 23 ExposedPorts map[nat.Port]struct{} 24 Tty bool // Attach standard streams to a tty, including stdin if it is not closed. 25 OpenStdin bool // Open stdin 26 StdinOnce bool // If true, close stdin after the 1 attached client disconnects. 27 Env []string 28 Cmd []string 29 Image string // Name of the image as it was passed by the operator (eg. could be symbolic) 30 Volumes map[string]struct{} 31 WorkingDir string 32 Entrypoint []string 33 NetworkDisabled bool 34 MacAddress string 35 OnBuild []string 36 SecurityOpt []string 37 Labels map[string]string 38 } 39 40 func ContainerConfigFromJob(job *engine.Job) *Config { 41 config := &Config{ 42 Hostname: job.Getenv("Hostname"), 43 Domainname: job.Getenv("Domainname"), 44 User: job.Getenv("User"), 45 Memory: job.GetenvInt64("Memory"), 46 MemorySwap: job.GetenvInt64("MemorySwap"), 47 CpuShares: job.GetenvInt64("CpuShares"), 48 Cpuset: job.Getenv("Cpuset"), 49 AttachStdin: job.GetenvBool("AttachStdin"), 50 AttachStdout: job.GetenvBool("AttachStdout"), 51 AttachStderr: job.GetenvBool("AttachStderr"), 52 Tty: job.GetenvBool("Tty"), 53 OpenStdin: job.GetenvBool("OpenStdin"), 54 StdinOnce: job.GetenvBool("StdinOnce"), 55 Image: job.Getenv("Image"), 56 WorkingDir: job.Getenv("WorkingDir"), 57 NetworkDisabled: job.GetenvBool("NetworkDisabled"), 58 MacAddress: job.Getenv("MacAddress"), 59 } 60 job.GetenvJson("ExposedPorts", &config.ExposedPorts) 61 job.GetenvJson("Volumes", &config.Volumes) 62 if PortSpecs := job.GetenvList("PortSpecs"); PortSpecs != nil { 63 config.PortSpecs = PortSpecs 64 } 65 if Env := job.GetenvList("Env"); Env != nil { 66 config.Env = Env 67 } 68 if Cmd := job.GetenvList("Cmd"); Cmd != nil { 69 config.Cmd = Cmd 70 } 71 72 job.GetenvJson("Labels", &config.Labels) 73 74 if Entrypoint := job.GetenvList("Entrypoint"); Entrypoint != nil { 75 config.Entrypoint = Entrypoint 76 } 77 return config 78 }