Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit ec42333

Browse files
committed
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> (cherry picked from commit d470252e8742867797a58933f7b4ba34494af2ed) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 10df1f55f15948905554822f7d0c270a7335a87f Component: engine
1 parent a62d4a6 commit ec42333

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

components/engine/cmd/dockerd/daemon.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,17 @@ func newAPIServerConfig(cli *DaemonCli) (*apiserver.Config, error) {
608608

609609
func loadListeners(cli *DaemonCli, serverConfig *apiserver.Config) ([]string, error) {
610610
var hosts []string
611+
seen := make(map[string]struct{}, len(cli.Config.Hosts))
612+
611613
for i := 0; i < len(cli.Config.Hosts); i++ {
612614
var err error
613615
if cli.Config.Hosts[i], err = dopts.ParseHost(cli.Config.TLS, honorXDG, cli.Config.Hosts[i]); err != nil {
614616
return nil, errors.Wrapf(err, "error parsing -H %s", cli.Config.Hosts[i])
615617
}
618+
if _, ok := seen[cli.Config.Hosts[i]]; ok {
619+
continue
620+
}
621+
seen[cli.Config.Hosts[i]] = struct{}{}
616622

617623
protoAddr := cli.Config.Hosts[i]
618624
protoAddrParts := strings.SplitN(protoAddr, "://", 2)

0 commit comments

Comments
 (0)