diff --git a/libnetwork/diagnostic/server.go b/libnetwork/diagnostic/server.go index da88b0fd4b..a919631493 100644 --- a/libnetwork/diagnostic/server.go +++ b/libnetwork/diagnostic/server.go @@ -4,7 +4,9 @@ import ( "context" "encoding/json" "fmt" + "net" "net/http" + "strconv" "sync" "sync/atomic" @@ -91,7 +93,10 @@ func (s *Server) EnableDiagnostic(ip string, port int) { } logrus.Infof("Starting the diagnostic server listening on %d for commands", port) - srv := &http.Server{Addr: fmt.Sprintf("%s:%d", ip, port), Handler: s} + srv := &http.Server{ + Addr: net.JoinHostPort(ip, strconv.Itoa(port)), + Handler: s, + } s.srv = srv s.enable = 1 go func(n *Server) {