{"record":{"id":"303982274dbf83ba","repo":"amir20/dozzle","slug":"container-not-found","errorCode":null,"errorMessage":"container not found","messagePattern":"container not found","errorType":"error_code","errorClass":"ErrContainerNotFound","httpStatus":404,"severity":"warning","filePath":"internal/container/container_store.go","lineNumber":95,"sourceCode":"\tevent := ContainerEvent{\n\t\tName:      \"update\",\n\t\tHost:      updated.Host,\n\t\tActorID:   updated.ID,\n\t\tTime:      time.Now(),\n\t\tContainer: updated,\n\t}\n\ts.subscribers.Range(func(ctx context.Context, events chan<- ContainerEvent) bool {\n\t\tselect {\n\t\tcase events <- event:\n\t\tcase <-ctx.Done():\n\t\t\ts.subscribers.Delete(ctx)\n\t\t}\n\t\treturn true\n\t})\n}\n\nvar (\n\tErrContainerNotFound = errors.New(\"container not found\")\n\tmaxFetchParallelism  = int64(30)\n)\n\nfunc (s *ContainerStore) checkConnectivity() error {\n\tif s.connected.CompareAndSwap(false, true) {\n\t\tgo func() {\n\t\t\tlog.Debug().Str(\"host\", s.client.Host().Name).Msg(\"docker store subscribing docker events\")\n\t\t\terr := s.client.ContainerEvents(s.ctx, s.events)\n\t\t\tif err != nil && !errors.Is(err, context.Canceled) {\n\t\t\t\tlog.Error().Err(err).Str(\"host\", s.client.Host().Name).Msg(\"docker store unexpectedly disconnected from docker events\")\n\t\t\t}\n\t\t\ts.connected.Store(false)\n\t\t}()\n\n\t\tctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)\n\t\tdefer cancel()\n\t\tif containers, err := s.client.ListContainers(ctx, s.labels); err != nil {\n\t\t\treturn err","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/container/container_store.go#L77-L113","documentation":"ErrContainerNotFound is the sentinel returned by ContainerStore.FindContainer / findContainerWithHost when the requested container id isn't in the store's valid set or isn't found in the loaded list. HTTP handlers translate it to a 404-style response.","triggerScenarios":"FindContainer called with an id absent from the store: id filtered out by the user's access control (validIDMap miss, line 205) or simply not present (line 231), e.g. container removed, wrong host, or stale id.","commonSituations":"Bookmarking/refreshing a page for a container that was deleted or restarted with a new id; multi-host setups where the container lives on a different host; filtered containers hidden by authorization rules; store not yet populated right after startup.","solutions":["Verify the container id is current (docker ps) and belongs to the host being queried","Confirm the container isn't excluded by your auth/authorization filter (validIDMap)","Refresh the container list; containers get new ids on recreate","Handle the 404 in the UI by redirecting to the container list instead of surfacing a raw error"],"exampleFix":"// caller pattern\ncontainer, err := store.FindContainer(id)\nif errors.Is(err, container.ErrContainerNotFound) {\n    http.Error(w, \"container not found\", http.StatusNotFound)\n    return\n}","handlingStrategy":"try-catch","validationCode":"// frontend: only open container pages from freshly listed containers\nconst exists = containers.value.some((c) => c.id === id);\nif (!exists) router.replace(\"/\");","typeGuard":null,"tryCatchPattern":"container, err := store.FindContainer(id)\nif errors.Is(err, container.ErrContainerNotFound) {\n    http.Error(w, \"container not found\", http.StatusNotFound)\n    return\n}","preventionTips":["Navigate to containers from live list data, not stale bookmarks","Remember containers get new ids on recreate; re-resolve by name/label when needed","In multi-host setups, query the correct host","Always compare with errors.Is, not string equality"],"tags":["docker","go","container","not-found"],"backgroundTag":"resource-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"}