{"record":{"id":"cb530eca7ffb4c19","repo":"amir20/dozzle","slug":"local-host-not-found","errorCode":null,"errorMessage":"local host not found","messagePattern":"local host not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/support/docker/multi_host_service.go","lineNumber":176,"sourceCode":"func (m *MultiHostService) Hosts() []container.Host {\n\tctx, cancel := context.WithTimeout(context.Background(), m.timeout)\n\tdefer cancel()\n\treturn m.manager.Hosts(ctx)\n}\n\nfunc (m *MultiHostService) LocalHost() (container.Host, error) {\n\tfor _, host := range m.Hosts() {\n\t\tif host.Type == \"local\" {\n\t\t\treturn host, nil\n\t\t}\n\t}\n\t// Swarm mode marks every host as \"swarm\" so the loop above never matches.\n\t// Fall back to the local docker client directly — its host ID is stable\n\t// per node and is what callers (cloud client instance ID, etc.) actually want.\n\tfor _, client := range m.manager.LocalClients() {\n\t\treturn client.Host(), nil\n\t}\n\treturn container.Host{}, fmt.Errorf(\"local host not found\")\n}\n\nfunc (m *MultiHostService) SubscribeAvailableHosts(ctx context.Context, hosts chan<- container.Host) {\n\tm.manager.Subscribe(ctx, hosts)\n}\n\nfunc (m *MultiHostService) LocalClients() []container.Client {\n\treturn m.manager.LocalClients()\n}\n\nfunc (m *MultiHostService) LocalClientServices() []container_support.ClientService {\n\treturn m.manager.LocalClientServices()\n}\n\n// ClientServices returns every client this Dozzle serves — the local docker\n// daemon, --remote-host daemons and --remote-agent agents alike. Unlike\n// LocalClientServices it does not filter by client type, so a caller that needs\n// the whole fleet (the cloud client) sees agents too.","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/support/docker/multi_host_service.go#L158-L194","documentation":"`MultiHostService.LocalHost` tries to identify the local host among connected clients; in Swarm mode no host matches that check, so it falls back to the first local Docker client. If the manager has no local clients at all, this error is returned.","triggerScenarios":"Calling LocalHost() when manager.LocalClients() is empty: Docker client failed to initialize (daemon unreachable, socket not mounted) or is still connecting during startup.","commonSituations":"Cloud client requesting an instance ID before the local Docker connection is established; running Dozzle without access to /var/run/docker.sock; transient daemon unavailability.","solutions":["Ensure the Docker socket is mounted and accessible (/var/run/docker.sock) and the daemon is running","Wait/retry until the RetriableClientManager has established the local client connection","Check DOZZLE environment/config so local mode isn't accidentally disabled","Check Dozzle startup logs for local Docker client connection errors"],"exampleFix":"// before\nhost, err := multiHostService.LocalHost() // immediately at startup\n// after\n// wait for clients, or guard:\nif host, err := multiHostService.LocalHost(); err != nil { time.Sleep(time.Second); retry() }","handlingStrategy":"retry","validationCode":"// Go: wait until local docker client is ready\npoll.Poll(time.Second, 30*time.Second, func() bool { return multiHostService.List() != nil })","typeGuard":null,"tryCatchPattern":"host, err := multiHostService.LocalHost()\nif err != nil {\n  time.Sleep(time.Second)\n  host, err = multiHostService.LocalHost()\n  if err != nil { log.Fatal(\"no local docker client: check socket mount\") }\n}","preventionTips":["Mount /var/run/docker.sock read-only into the dozzle container","Delay cloud instance-ID registration until clients are connected"],"tags":["docker","multi-host","initialization"],"backgroundTag":"entity-not-found","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"}