Merge pull request #11288 from estesp/warn-on-localhost-dns

Add warning for --dns flag set to localhost addresses.
This commit is contained in:
Jessie Frazelle
2015-03-10 12:03:46 -07:00
3 changed files with 35 additions and 8 deletions
+13
View File
@@ -37,6 +37,7 @@ import (
"github.com/docker/docker/pkg/fileutils"
"github.com/docker/docker/pkg/homedir"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/networkfs/resolvconf"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/parsers/filters"
"github.com/docker/docker/pkg/promise"
@@ -2264,6 +2265,18 @@ func (cli *DockerCli) CmdRun(args ...string) error {
if err != nil {
utils.ReportError(cmd, err.Error(), true)
}
if len(hostConfig.Dns) > 0 {
// check the DNS settings passed via --dns against
// localhost regexp to warn if they are trying to
// set a DNS to a localhost address
for _, dnsIP := range hostConfig.Dns {
if resolvconf.IsLocalhost(dnsIP) {
fmt.Fprintf(cli.err, "WARNING: Localhost DNS setting (--dns=%s) may fail in containers.\n", dnsIP)
break
}
}
}
if config.Image == "" {
cmd.Usage()
return nil