amir20/dozzle · warning · ErrContainerNotFound

container not found

Error message

container not found

What it means

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.

Solutions

  1. Verify the container id is current (docker ps) and belongs to the host being queried
  2. Confirm the container isn't excluded by your auth/authorization filter (validIDMap)
  3. Refresh the container list; containers get new ids on recreate
  4. Handle the 404 in the UI by redirecting to the container list instead of surfacing a raw error

Example fix

// caller pattern
container, err := store.FindContainer(id)
if errors.Is(err, container.ErrContainerNotFound) {
    http.Error(w, "container not found", http.StatusNotFound)
    return
}
Defensive patterns

Strategy: try-catch

Validate before calling

// frontend: only open container pages from freshly listed containers
const exists = containers.value.some((c) => c.id === id);
if (!exists) router.replace("/");

Try / catch

container, err := store.FindContainer(id)
if errors.Is(err, container.ErrContainerNotFound) {
    http.Error(w, "container not found", http.StatusNotFound)
    return
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of amir20/dozzle@d9463cbe21 (2026-09-07). Data as JSON: /api/errors/303982274dbf83ba. Report an issue: GitHub.

Appendix: source

Thrown at internal/container/container_store.go:95

	event := ContainerEvent{
		Name:      "update",
		Host:      updated.Host,
		ActorID:   updated.ID,
		Time:      time.Now(),
		Container: updated,
	}
	s.subscribers.Range(func(ctx context.Context, events chan<- ContainerEvent) bool {
		select {
		case events <- event:
		case <-ctx.Done():
			s.subscribers.Delete(ctx)
		}
		return true
	})
}

var (
	ErrContainerNotFound = errors.New("container not found")
	maxFetchParallelism  = int64(30)
)

func (s *ContainerStore) checkConnectivity() error {
	if s.connected.CompareAndSwap(false, true) {
		go func() {
			log.Debug().Str("host", s.client.Host().Name).Msg("docker store subscribing docker events")
			err := s.client.ContainerEvents(s.ctx, s.events)
			if err != nil && !errors.Is(err, context.Canceled) {
				log.Error().Err(err).Str("host", s.client.Host().Name).Msg("docker store unexpectedly disconnected from docker events")
			}
			s.connected.Store(false)
		}()

		ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
		defer cancel()
		if containers, err := s.client.ListContainers(ctx, s.labels); err != nil {
			return err

View on GitHub (pinned to d9463cbe21)