Signed-off-by: Shijiang Wei <mountkin@gmail.com>
| ... | ... |
@@ -156,6 +156,13 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea |
| 156 | 156 |
req.Host = cli.addr |
| 157 | 157 |
|
| 158 | 158 |
dial, err := cli.dial() |
| 159 |
+ if err != nil {
|
|
| 160 |
+ if strings.Contains(err.Error(), "connection refused") {
|
|
| 161 |
+ return fmt.Errorf("Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?")
|
|
| 162 |
+ } |
|
| 163 |
+ return err |
|
| 164 |
+ } |
|
| 165 |
+ |
|
| 159 | 166 |
// When we set up a TCP connection for hijack, there could be long periods |
| 160 | 167 |
// of inactivity (a long running command with no output) that in certain |
| 161 | 168 |
// network setups may cause ECONNTIMEOUT, leaving the client in an unknown |
| ... | ... |
@@ -165,12 +172,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea |
| 165 | 165 |
tcpConn.SetKeepAlive(true) |
| 166 | 166 |
tcpConn.SetKeepAlivePeriod(30 * time.Second) |
| 167 | 167 |
} |
| 168 |
- if err != nil {
|
|
| 169 |
- if strings.Contains(err.Error(), "connection refused") {
|
|
| 170 |
- return fmt.Errorf("Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?")
|
|
| 171 |
- } |
|
| 172 |
- return err |
|
| 173 |
- } |
|
| 168 |
+ |
|
| 174 | 169 |
clientconn := httputil.NewClientConn(dial, nil) |
| 175 | 170 |
defer clientconn.Close() |
| 176 | 171 |
|