... | ... |
@@ -27,8 +27,8 @@ func ConfigFromJob(job *engine.Job) *DaemonConfig { |
27 | 27 |
config.Root = job.Getenv("Root") |
28 | 28 |
config.AutoRestart = job.GetenvBool("AutoRestart") |
29 | 29 |
config.EnableCors = job.GetenvBool("EnableCors") |
30 |
- if dns := job.Getenv("Dns"); dns != "" { |
|
31 |
- config.Dns = []string{dns} |
|
30 |
+ if dns := job.GetenvList("Dns"); dns != nil { |
|
31 |
+ config.Dns = dns |
|
32 | 32 |
} |
33 | 33 |
config.EnableIptables = job.GetenvBool("EnableIptables") |
34 | 34 |
if br := job.Getenv("BridgeIface"); br != "" { |
... | ... |
@@ -33,13 +33,14 @@ func main() { |
33 | 33 |
pidfile = flag.String("p", "/var/run/docker.pid", "Path to use for daemon PID file") |
34 | 34 |
flRoot = flag.String("g", "/var/lib/docker", "Path to use as the root of the docker runtime") |
35 | 35 |
flEnableCors = flag.Bool("api-enable-cors", false, "Enable CORS headers in the remote API") |
36 |
- flDns = flag.String("dns", "", "Force docker to use specific DNS servers") |
|
36 |
+ flDns = docker.NewListOpts(docker.ValidateIp4Address) |
|
37 | 37 |
flEnableIptables = flag.Bool("iptables", true, "Disable docker's addition of iptables rules") |
38 | 38 |
flDefaultIp = flag.String("ip", "0.0.0.0", "Default IP address to use when binding container ports") |
39 | 39 |
flInterContainerComm = flag.Bool("icc", true, "Enable inter-container communication") |
40 | 40 |
flGraphDriver = flag.String("s", "", "Force the docker runtime to use a specific storage driver") |
41 | 41 |
flHosts = docker.NewListOpts(docker.ValidateHost) |
42 | 42 |
) |
43 |
+ flag.Var(&flDns, "dns", "Force docker to use specific DNS servers") |
|
43 | 44 |
flag.Var(&flHosts, "H", "Multiple tcp://host:port or unix://path/to/socket to bind in daemon mode, single connection otherwise") |
44 | 45 |
|
45 | 46 |
flag.Parse() |
... | ... |
@@ -73,7 +74,7 @@ func main() { |
73 | 73 |
job.Setenv("Root", *flRoot) |
74 | 74 |
job.SetenvBool("AutoRestart", *flAutoRestart) |
75 | 75 |
job.SetenvBool("EnableCors", *flEnableCors) |
76 |
- job.Setenv("Dns", *flDns) |
|
76 |
+ job.SetenvList("Dns", flDns.GetAll()) |
|
77 | 77 |
job.SetenvBool("EnableIptables", *flEnableIptables) |
78 | 78 |
job.Setenv("BridgeIface", *bridgeName) |
79 | 79 |
job.Setenv("DefaultIp", *flDefaultIp) |
... | ... |
@@ -5,6 +5,7 @@ import ( |
5 | 5 |
"github.com/dotcloud/docker/utils" |
6 | 6 |
"os" |
7 | 7 |
"path/filepath" |
8 |
+ "regexp" |
|
8 | 9 |
"strings" |
9 | 10 |
) |
10 | 11 |
|
... | ... |
@@ -134,3 +135,12 @@ func ValidateHost(val string) (string, error) { |
134 | 134 |
} |
135 | 135 |
return host, nil |
136 | 136 |
} |
137 |
+ |
|
138 |
+func ValidateIp4Address(val string) (string, error) { |
|
139 |
+ re := regexp.MustCompile(`^(([0-9]+\.){3}([0-9]+))\s*$`) |
|
140 |
+ var ns = re.FindSubmatch([]byte(val)) |
|
141 |
+ if len(ns) > 0 { |
|
142 |
+ return string(ns[1]), nil |
|
143 |
+ } |
|
144 |
+ return "", fmt.Errorf("%s is not an ip4 address", val) |
|
145 |
+} |