mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Solve an issue with the -dns in daemon mode
This commit is contained in:
parent
a3f6054f97
commit
afd325a884
1 changed files with 8 additions and 8 deletions
|
@ -33,10 +33,7 @@ func main() {
|
||||||
bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge")
|
bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge")
|
||||||
pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID")
|
pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID")
|
||||||
flHost := flag.String("H", fmt.Sprintf("%s:%d", host, port), "Host:port to bind/connect to")
|
flHost := flag.String("H", fmt.Sprintf("%s:%d", host, port), "Host:port to bind/connect to")
|
||||||
|
flDns := flag.String("dns", "", "Set custom dns servers")
|
||||||
flags := flag.NewFlagSet("docker", flag.ContinueOnError)
|
|
||||||
var flDns docker.ListOpts
|
|
||||||
flags.Var(&flDns, "dns", "Set custom dns servers")
|
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *bridgeName != "" {
|
if *bridgeName != "" {
|
||||||
|
@ -70,7 +67,7 @@ func main() {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := daemon(*pidfile, host, port, *flAutoRestart, flDns); err != nil {
|
if err := daemon(*pidfile, host, port, *flAutoRestart, *flDns); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
@ -109,7 +106,7 @@ func removePidFile(pidfile string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func daemon(pidfile, addr string, port int, autoRestart bool, flDns docker.ListOpts) error {
|
func daemon(pidfile, addr string, port int, autoRestart bool, flDns string) error {
|
||||||
if addr != "127.0.0.1" {
|
if addr != "127.0.0.1" {
|
||||||
log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
|
log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
|
||||||
}
|
}
|
||||||
|
@ -126,8 +123,11 @@ func daemon(pidfile, addr string, port int, autoRestart bool, flDns docker.ListO
|
||||||
removePidFile(pidfile)
|
removePidFile(pidfile)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}()
|
}()
|
||||||
|
var dns []string
|
||||||
server, err := docker.NewServer(autoRestart, flDns)
|
if flDns != "" {
|
||||||
|
dns = []string{flDns}
|
||||||
|
}
|
||||||
|
server, err := docker.NewServer(autoRestart, dns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue