Merge pull request #415 from jlhawn/client_dial_enable_tcp_keepalive

Enable TCP Keep-Alive in Docker client
Upstream-commit: f7b78dc137
Component: cli
This commit is contained in:
Sebastiaan van Stijn
2017-08-03 19:42:57 +02:00
committed by GitHub

View File

@ -2,9 +2,11 @@ package command
import (
"io"
"net"
"net/http"
"os"
"runtime"
"time"
"github.com/docker/cli/cli"
cliconfig "github.com/docker/cli/cli/config"
@ -214,6 +216,10 @@ func newHTTPClient(host string, tlsOptions *tlsconfig.Options) (*http.Client, er
}
tr := &http.Transport{
TLSClientConfig: config,
DialContext: (&net.Dialer{
KeepAlive: 30 * time.Second,
Timeout: 30 * time.Second,
}).DialContext,
}
proto, addr, _, err := client.ParseHost(host)
if err != nil {