cmd/dockerd: reserve port before creating sockets/listeners
This prevents creating a socket and touching the filesystem before trying to use a port that was already in use by a container. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
986725b466
commit
b053376741
1 changed files with 4 additions and 4 deletions
|
@ -719,16 +719,16 @@ func loadListeners(cli *DaemonCli, serverConfig *apiserver.Config) ([]string, er
|
|||
}
|
||||
}
|
||||
}
|
||||
ls, err := listeners.Init(proto, addr, serverConfig.SocketGroup, serverConfig.TLSConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// If we're binding to a TCP port, make sure that a container doesn't try to use it.
|
||||
if proto == "tcp" {
|
||||
if err := allocateDaemonPort(addr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
ls, err := listeners.Init(proto, addr, serverConfig.SocketGroup, serverConfig.TLSConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.Debugf("Listener created for HTTP on %s (%s)", proto, addr)
|
||||
hosts = append(hosts, protoAddrParts[1])
|
||||
cli.api.Accept(addr, ls...)
|
||||
|
|
Loading…
Add table
Reference in a new issue