瀏覽代碼

Add a timeout when trying to connect to the server, otherwise sometimes it just hangs

Signed-off-by: Doug Davis <dug@us.ibm.com>
Doug Davis 10 年之前
父節點
當前提交
f013aa7f96
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      api/client/utils.go

+ 3 - 1
api/client/utils.go

@@ -16,6 +16,7 @@ import (
 	"strconv"
 	"strings"
 	"syscall"
+	"time"
 
 	"github.com/docker/docker/api"
 	"github.com/docker/docker/dockerversion"
@@ -34,7 +35,8 @@ func (cli *DockerCli) HTTPClient() *http.Client {
 	tr := &http.Transport{
 		TLSClientConfig: cli.tlsConfig,
 		Dial: func(network, addr string) (net.Conn, error) {
-			return net.Dial(cli.proto, cli.addr)
+			// Why 32? See issue 8035
+			return net.DialTimeout(cli.proto, cli.addr, 32*time.Second)
 		},
 	}
 	return &http.Client{Transport: tr}