{"record":{"id":"8d3cb7c8786e5587","repo":"docker/cli","slug":"command-v-did-not-exit-after-v-stderr-q","errorCode":null,"errorMessage":"command %v did not exit after %v: stderr=%q","messagePattern":"command (.+?) did not exit after (.+?): stderr=%q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/connhelper/commandconn/commandconn.go","lineNumber":151,"sourceCode":"\n\tc.cmdMutex.Lock()\n\tdefer c.cmdMutex.Unlock()\n\n\tvar werr error\n\tif c.cmdExited.Load() {\n\t\twerr = c.cmdWaitErr\n\t} else {\n\t\twerrCh := make(chan error)\n\t\tgo func() { werrCh <- c.cmd.Wait() }()\n\t\tselect {\n\t\tcase werr = <-werrCh:\n\t\t\tc.cmdWaitErr = werr\n\t\t\tc.cmdExited.Store(true)\n\t\tcase <-time.After(10 * time.Second):\n\t\t\tc.stderrMu.Lock()\n\t\t\tstderr := c.stderr.String()\n\t\t\tc.stderrMu.Unlock()\n\t\t\treturn fmt.Errorf(\"command %v did not exit after %v: stderr=%q\", c.cmd.Args, err, stderr)\n\t\t}\n\t}\n\n\tif werr == nil {\n\t\treturn err\n\t}\n\tc.stderrMu.Lock()\n\tstderr := c.stderr.String()\n\tc.stderrMu.Unlock()\n\treturn fmt.Errorf(\"command %v has exited with %v, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=%s\", c.cmd.Args, werr, stderr)\n}\n\nfunc ignorableCloseError(err error) bool {\n\treturn strings.Contains(err.Error(), os.ErrClosed.Error())\n}\n\nfunc (c *commandConn) Read(p []byte) (int, error) {\n\tn, err := c.stdout.Read(p)","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/connhelper/commandconn/commandconn.go#L133-L169","documentation":"Raised by commandConn.handleEOF (commandconn.go:147-151) when the underlying command's stdout/stdin returned io.EOF but the command process did not terminate within 10 seconds of calling cmd.Wait(). This is a watchdog error: the data stream ended yet the process hangs, so the connection cannot be cleanly finalized.","triggerScenarios":"Reading/writing a commandConn (e.g. an ssh tunnel to a remote Docker daemon) yields io.EOF; handleEOF spawns a goroutine calling cmd.Wait() with a 10s timeout. If Wait does not return within 10s, this error is produced including the captured stderr.","commonSituations":"The remote ssh process is hung (network black-hole, remote Docker daemon wedged, ssh multiplexing control socket stuck), or the remote command blocks waiting on a resource. The remote host may be unreachable mid-stream, or an older/buggy ssh client/server combination leaves a zombie. Also seen when the remote Docker daemon is not 18.09+.","solutions":["Check network connectivity to the remote host and that the remote Docker daemon is responsive.","Inspect the embedded stderr (logged at debug level by the stderrWriter) for the actual ssh/remote error.","Kill stale ssh control sockets / processes (`pkill -f 'ssh.*docker'`).","Verify Docker 18.09+ is installed on the remote host (required for `docker system dial-stdio`).","Retry the connection; if persistent, simplify the DOCKER_HOST ssh URL and test ssh manually."],"exampleFix":"# test the underlying ssh command manually to surface the real error\nssh -o ConnectTimeout=30 -T <user>@<host> docker --host=unix:///var/run/docker.sock system dial-stdio","handlingStrategy":"retry","validationCode":"// Pre-flight: confirm the ssh command can reach a docker daemon before use.\nif err := exec.Command(\"ssh\", \"-o\", \"ConnectTimeout=30\", \"-T\", userHost, \"docker\", \"version\").Run(); err != nil {\n    return fmt.Errorf(\"remote docker unreachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"// commandConn errors propagate through the http.Client; treat as transient or fatal.\nresp, err := httpClient.Do(req)\nif err != nil && strings.Contains(err.Error(), \"did not exit after\") {\n    // stale ssh process; retry once after cleanup\n    exec.Command(\"pkill\", \"-f\", \"ssh.*dial-stdio\").Run()\n}","preventionTips":["Keep ssh ControlMaster/ControlPath clean; stale sockets cause hangs.","Ensure the remote Docker daemon is 18.09+ and healthy.","Set `-o ConnectTimeout=30` (the helper does, but verify your ssh config doesn't override)."],"tags":["connhelper","commandconn","ssh","timeout","network"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}