Skip to content

Commit 5e3f6e7

Browse files
author
Guillaume J. Charmes
committed
Change the default Host affectation to not rely on slice
1 parent 1beb500 commit 5e3f6e7

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

docker/docker.go

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ func main() {
3838
flDefaultIp = flag.String("ip", "0.0.0.0", "Default IP address to use when binding container ports")
3939
flInterContainerComm = flag.Bool("icc", true, "Enable inter-container communication")
4040
flGraphDriver = flag.String("s", "", "Force the docker runtime to use a specific storage driver")
41-
42-
flHosts = docker.ListOpts{}
41+
flHosts = docker.NewListOpts(docker.ValidateHost)
4342
)
44-
flHosts.Set(fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET))
4543
flag.Var(&flHosts, "H", "Multiple tcp://host:port or unix://path/to/socket to bind in daemon mode, single connection otherwise")
4644

4745
flag.Parse()
@@ -50,17 +48,9 @@ func main() {
5048
showVersion()
5149
return
5250
}
53-
// if flHosts.Len() > 1 {
54-
// flHosts = flHosts[1:] //trick to display a nice default value in the usage
55-
// }
56-
for _, flHost := range flHosts.GetAll() {
57-
host, err := utils.ParseHost(docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT, flHost)
58-
if err == nil {
59-
flHosts.Set(host)
60-
flHosts.Delete(flHost)
61-
} else {
62-
log.Fatal(err)
63-
}
51+
if flHosts.Len() == 0 {
52+
// If we do not have a host, default to unix socket
53+
flHosts.Set(fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET))
6454
}
6555

6656
if *flDebug {

0 commit comments

Comments
 (0)