{"record":{"id":"92d1b51b471d1a02","repo":"GoogleContainerTools/skaffold","slug":"error-getting-docker-client-s","errorCode":null,"errorMessage":"error getting docker client: %s","messagePattern":"error getting docker client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/docker/client.go","lineNumber":138,"sourceCode":"\n\t\tcommand := exec.Command(\"docker\", \"context\", \"inspect\", \"--format\", \"{{.Endpoints.docker.Host}}\")\n\t\tout, err := util.RunCmdOut(context.TODO(), command)\n\t\tif err != nil {\n\t\t\t// docker cli not installed.\n\t\t\tlog.Entry(context.TODO()).Warnf(\"Could not get docker context: %s, falling back to the default docker host\", err)\n\t\t} else {\n\t\t\ts := strings.TrimSpace(string(out))\n\t\t\t// output can be empty if user uses docker as alias for podman\n\t\t\tif len(s) > 0 {\n\t\t\t\topts = append(opts, client.WithHost(s))\n\t\t\t}\n\t\t}\n\t}\n\n\topts = append(opts, client.WithAPIVersionNegotiation())\n\tcli, err := client.New(opts...)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"error getting docker client: %s\", err)\n\t}\n\n\treturn nil, cli, nil\n}\n\ntype ExitCoder interface {\n\tExitCode() int\n}\n\n// newMinikubeAPIClient returns a docker client using the environment variables\n// provided by minikube.\nfunc newMinikubeAPIClient(ctx context.Context, minikubeProfile string) ([]string, client.APIClient, error) {\n\tenv, err := getMinikubeDockerEnv(ctx, minikubeProfile)\n\tif err != nil {\n\t\t// When minikube uses the infamous `none` driver, `minikube docker-env` will exit with\n\t\t// code 51 (>= 1.13.0) or 64 (< 1.13.0).  Note that exit code 51 was unused prior to 1.13.0\n\t\t// so it is safe to check here without knowing the minikube version.\n\t\tvar exitError ExitCoder","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/docker/client.go#L120-L156","documentation":"This error is wrapped by newEnvAPIClient when the Docker SDK's client.New(opts...) call fails to construct a Docker client. Skaffold builds the client from resolved environment options (DOCKER_HOST, certs, etc.) and adds API version negotiation; any failure at this stage means the Docker client itself could not be created, typically due to an invalid Docker host address or bad TLS configuration. The underlying SDK error is appended via %s.","triggerScenarios":"Calling newAPIClient, newMinikubeAPIClient, or the anonymous caller path when client.New(opts...) returns an error — e.g. DOCKER_HOST set to a malformed URL like 'tcp://:2375', an unsupported scheme, or invalid client cert/key paths passed as options.","commonSituations":"DOCKER_HOST contains a typo or unsupported protocol (http:// instead of tcp://); DOCKER_TLS_VERIFY/DOCKER_CERT_PATH point to missing or unreadable certificate files; a minikube docker-env export produced a bad DOCKER_HOST value; Docker SDK cannot parse the connection string.","solutions":["Check DOCKER_HOST: run 'docker context ls' or 'echo $DOCKER_HOST' and fix malformed values (must be unix:///path or tcp://host:port).","If using TLS, verify DOCKER_CERT_PATH contains ca.pem, cert.pem, key.pem and DOCKER_TLS_VERIFY=1 is set correctly.","Unset conflicting env vars ('unset DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_PATH') to fall back to the default local socket.","Run 'docker version' with the same environment to confirm the Docker CLI can connect; fix whatever it reports.","If it came from a minikube profile, re-run 'minikube -p <profile> docker-env' and re-export the values."],"exampleFix":"// before\nexport DOCKER_HOST=\"http://localhost:2375\"\n// after\nexport DOCKER_HOST=\"tcp://localhost:2375\"","handlingStrategy":"validation","validationCode":"host := os.Getenv(\"DOCKER_HOST\")\nif host != \"\" {\n    u, err := url.Parse(host)\n    if err != nil || (u.Scheme != \"unix\" && u.Scheme != \"tcp\" && u.Scheme != \"npipe\" && u.Scheme != \"ssh\") {\n        return fmt.Errorf(\"invalid DOCKER_HOST %q: must be unix://, tcp://, npipe:// or ssh://\", host)\n    }\n}\nif os.Getenv(\"DOCKER_TLS_VERIFY\") != \"\" {\n    for _, f := range []string{\"ca.pem\", \"cert.pem\", \"key.pem\"} {\n        if _, err := os.Stat(filepath.Join(os.Getenv(\"DOCKER_CERT_PATH\"), f)); err != nil {\n            return fmt.Errorf(\"missing TLS cert %s in DOCKER_CERT_PATH\", f)\n        }\n    }\n}","typeGuard":"func dockerHostValid(host string) bool {\n    if host == \"\" {\n        return true\n    }\n    u, err := url.Parse(host)\n    return err == nil && u.Scheme != \"\"\n}","tryCatchPattern":"cli, err := newAPIClient(ctx, cfg)\nif err != nil {\n    var derr *dockerClientError\n    if errors.As(err, &derr) {\n        log.Fatalf(\"Docker client setup failed: %v — check DOCKER_HOST/DOCKER_CERT_PATH\", err)\n    }\n    return err\n}","preventionTips":["Validate DOCKER_HOST URL scheme before invoking builds.","Keep DOCKER_CERT_PATH populated with ca.pem/cert.pem/key.pem when TLS is enabled.","Sanity-check the environment with 'docker version' before running Skaffold in CI.","Avoid mixing docker contexts and exported DOCKER_HOST env vars."],"tags":["docker","configuration","environment"],"backgroundTag":"docker-client-creation-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}