From fa164d03f1a4fcf7f5838cb2dae408761b5d6d33 Mon Sep 17 00:00:00 2001 From: Doug Davis Date: Mon, 15 Sep 2014 04:50:22 -0700 Subject: [PATCH] Add a timeout when trying to connect to the server, otherwise sometimes it just hangs Signed-off-by: Doug Davis Upstream-commit: f013aa7f96d7fc818f06f5b7fe0bbd20ff2d3294 Component: engine --- components/engine/api/client/utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/engine/api/client/utils.go b/components/engine/api/client/utils.go index e4ef8d3875..d018fb7328 100644 --- a/components/engine/api/client/utils.go +++ b/components/engine/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}