{"record":{"id":"bc3e09d3bd228299","repo":"hashicorp/nomad","slug":"failed-to-get-docker-client-v","errorCode":null,"errorMessage":"failed to get docker client: %v","messagePattern":"failed to get docker client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"drivers/docker/config.go","lineNumber":846,"sourceCode":"\t\t\treturn fmt.Errorf(\"failed to parse 'image_pull_timeout' duration: %v\", err)\n\t\t}\n\t}\n\n\tif err := validateAllowedNamespace(d.config.AllowedModes); err != nil {\n\t\treturn err\n\t}\n\td.config.allowRuntimes = make(map[string]struct{}, len(d.config.AllowRuntimesList))\n\tfor _, r := range d.config.AllowRuntimesList {\n\t\td.config.allowRuntimes[r] = struct{}{}\n\t}\n\n\tif c.AgentConfig != nil {\n\t\td.clientConfig = c.AgentConfig.Driver\n\t}\n\n\tdockerClient, err := d.getDockerClient()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get docker client: %v\", err)\n\t}\n\tcoordinatorConfig := &dockerCoordinatorConfig{\n\t\tctx:         d.ctx,\n\t\tclient:      dockerClient,\n\t\tcleanup:     d.config.GC.Image,\n\t\tlogger:      d.logger,\n\t\tremoveDelay: d.config.GC.imageDelayDuration,\n\t}\n\n\td.coordinator = newDockerCoordinator(coordinatorConfig)\n\n\td.danglingReconciler = newReconciler(d)\n\n\tgo d.recoverPauseContainers(d.ctx)\n\n\treturn nil\n}\n","sourceCodeStart":828,"sourceCodeEnd":864,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/docker/config.go#L828-L864","documentation":"During docker driver plugin setup (SetupClient), the driver creates a Docker API client via d.getDockerClient(). Any failure there — bad DOCKER_HOST, unreachable daemon, TLS problems — aborts driver initialization wrapped as \"failed to get docker client\". The driver cannot operate without a working Docker client connection.","triggerScenarios":"Calling driver setup when the Docker daemon is down, DOCKER_HOST points to a nonexistent socket/host, docker client API version negotiation fails, or TLS certs configured for the docker endpoint are invalid/missing.","commonSituations":"Nomad agent started before dockerd on the host; DOCKER_HOST env or plugin docker_endpoint misconfigured; running Nomad in a container without mounting /var/run/docker.sock; daemon socket permissions denied.","solutions":["Verify the Docker daemon is running: 'docker info' on the host; start/restart dockerd if needed.","Check the docker plugin config (docker_endpoint / DOCKER_HOST) points to a valid socket like unix:///var/run/docker.sock.","If Nomad runs in a container, mount the host docker socket and grant the nomad user permission (docker group / socket chmod).","Validate TLS settings (docker_tls_cacert/cert/key) and confirm the endpoint speaks a compatible API version.","Check nomad agent logs for the underlying wrapped error to distinguish connect-refused from permission or version errors."],"exampleFix":"// before\nplugin \"docker\" {\n  config {\n    docker_endpoint = \"unix:///var/run/docker.sock\"\n  }\n}\n// after (daemon on TCP with TLS)\nplugin \"docker\" {\n  config {\n    docker_endpoint = \"tcp://docker-host:2376\"\n    docker_tls_cacert = \"/etc/nomad/ca.pem\"\n    docker_tls_cert   = \"/etc/nomad/cert.pem\"\n    docker_tls_key    = \"/etc/nomad/key.pem\"\n  }\n}","handlingStrategy":"validation","validationCode":"// Pre-flight before driver setup\ncli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())\nif err != nil {\n    log.Fatalf(\"docker not reachable: %v\", err)\n}\nif _, err := cli.Ping(context.Background()); err != nil {\n    log.Fatalf(\"docker ping failed: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"catch the setup error, log the wrapped cause, and distinguish: connection refused (start dockerd) vs permission denied (fix socket/group) vs TLS (fix certs).","preventionTips":["Health-check the Docker daemon as a startup dependency (systemd Requires/After=docker.service).","Mount /var/run/docker.sock when Nomad runs in a container.","Pin docker_endpoint explicitly in the plugin config instead of relying on ambient DOCKER_HOST.","Keep client API version negotiation enabled."],"tags":["docker","connection","driver-setup"],"backgroundTag":"docker-daemon-unreachable","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}