Merge pull request #415 from jlhawn/client_dial_enable_tcp_keepalive

Enable TCP Keep-Alive in Docker client
This commit is contained in:
Sebastiaan van Stijn 2017-08-03 19:42:57 +02:00 committed by GitHub
commit f7b78dc137
1 changed files with 6 additions and 0 deletions

View File

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