{"record":{"id":"82ddb3d66f946b8f","repo":"amir20/dozzle","slug":"failed-to-create-docker-client-w","errorCode":null,"errorMessage":"failed to create docker client: %w","messagePattern":"failed to create docker client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/support/cli/agent_command.go","lineNumber":147,"sourceCode":"\nfunc (h *persistingNotificationHandler) ClearCloudDispatcher() {\n\th.manager.ClearCloudDispatcher()\n\th.cloudConfig.Store(nil)\n\tif h.onCloudSet != nil {\n\t\th.onCloudSet()\n\t}\n\tif err := os.Remove(\"./data/cloud.yml\"); err != nil && !os.IsNotExist(err) {\n\t\tlog.Error().Err(err).Msg(\"Could not remove cloud.yml on agent\")\n\t}\n}\n\nfunc (a *AgentCmd) Run(args Args, embeddedCerts embed.FS) error {\n\tif args.Mode != \"server\" {\n\t\treturn fmt.Errorf(\"agent command is only available in server mode\")\n\t}\n\tclient, err := docker.NewLocalClient(args.Hostname)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create docker client: %w\", err)\n\t}\n\tcerts, err := ReadCertificates(embeddedCerts, args.CertPath, args.KeyPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read certificates: %w\", err)\n\t}\n\n\tlistener, err := net.Listen(\"tcp\", args.Agent.Addr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to listen: %w\", err)\n\t}\n\tconst agentAddrFile = \"/tmp/dozzle-agent.addr\"\n\tif err := os.WriteFile(agentAddrFile, []byte(args.Agent.Addr), 0644); err != nil {\n\t\treturn fmt.Errorf(\"failed to write agent address file: %w\", err)\n\t}\n\tgo StartEvent(args, \"\", client, \"agent\")\n\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)\n\tdefer stop()","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/support/cli/agent_command.go#L129-L165","documentation":"Returned by AgentCmd.Run when docker.NewLocalClient fails to create a Docker API client for the local daemon. This wraps the underlying error (socket connection, TLS config, or API version negotiation failure). The agent cannot function without talking to the local Docker daemon, so startup aborts.","triggerScenarios":"Running `dozzle agent` when DOCKER_HOST points at an unreachable host, the Docker socket is missing or permission-denied, or the daemon is not running. Also fires when API version negotiation with the daemon fails.","commonSituations":"Agent started inside a container without mounting /var/run/docker.sock; Docker Desktop not running on the host; DOCKER_HOST set to a stale tcp:// endpoint; user lacks docker group membership.","solutions":["Verify the Docker daemon is running: `docker info` on the host.","Inside a container, mount the socket: `-v /var/run/docker.sock:/var/run/docker.sock`.","Check DOCKER_HOST is unset or points to a valid endpoint (unix:///var/run/docker.sock or tcp://host:2375).","If using tcp://, enable the daemon's TCP listener and confirm firewall access.","Check user permissions for the docker socket (add user to docker group)."],"exampleFix":"// before (docker-compose)\nservices:\n  agent:\n    image: amir20/dozzle:latest\n    command: agent\n// after\nservices:\n  agent:\n    image: amir20/dozzle:latest\n    command: agent\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock","handlingStrategy":"try-catch","validationCode":"if ! docker info >/dev/null 2>&1; then echo 'Docker daemon unreachable'; exit 1; fi","typeGuard":null,"tryCatchPattern":"if err := agentCmd.Run(args, embeddedCerts); err != nil {\n  var netErr net.Error\n  if errors.As(err, &netErr) { /* daemon/socket unreachable */ }\n  log.Fatal().Err(err).Msg(\"agent startup failed: docker client\")\n}","preventionTips":["Always mount /var/run/docker.sock when running the agent in a container","Sanity-check with `docker info` before launching the agent","Avoid overriding DOCKER_HOST unless you have a tcp daemon","Keep the agent user in the docker group"],"tags":["docker","agent","startup"],"backgroundTag":"connection-refused","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}