daemon: don't listen on the same address multiple times
Before this change: dockerd -H unix:///run/docker.sock -H unix:///run/docker.sock -H unix:///run/docker.sock ... INFO[2019-07-13T00:02:36.195090937Z] Daemon has completed initialization INFO[2019-07-13T00:02:36.215940441Z] API listen on /run/docker.sock INFO[2019-07-13T00:02:36.215933172Z] API listen on /run/docker.sock INFO[2019-07-13T00:02:36.215990566Z] API listen on /run/docker.sock After this change: dockerd -H unix:///run/docker.sock -H unix:///run/docker.sock -H unix:///run/docker.sock ... INFO[2019-07-13T00:01:37.533579874Z] Daemon has completed initialization INFO[2019-07-13T00:01:37.567045771Z] API listen on /run/docker.sock Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
47a84dcc64
commit
d470252e87
1 changed files with 6 additions and 0 deletions
|
@ -611,11 +611,17 @@ func newAPIServerConfig(cli *DaemonCli) (*apiserver.Config, error) {
|
|||
|
||||
func loadListeners(cli *DaemonCli, serverConfig *apiserver.Config) ([]string, error) {
|
||||
var hosts []string
|
||||
seen := make(map[string]struct{}, len(cli.Config.Hosts))
|
||||
|
||||
for i := 0; i < len(cli.Config.Hosts); i++ {
|
||||
var err error
|
||||
if cli.Config.Hosts[i], err = dopts.ParseHost(cli.Config.TLS, honorXDG, cli.Config.Hosts[i]); err != nil {
|
||||
return nil, errors.Wrapf(err, "error parsing -H %s", cli.Config.Hosts[i])
|
||||
}
|
||||
if _, ok := seen[cli.Config.Hosts[i]]; ok {
|
||||
continue
|
||||
}
|
||||
seen[cli.Config.Hosts[i]] = struct{}{}
|
||||
|
||||
protoAddr := cli.Config.Hosts[i]
|
||||
protoAddrParts := strings.SplitN(protoAddr, "://", 2)
|
||||
|
|
Loading…
Reference in a new issue