Skip to content

Docker: watcher hangs indefinitely and locks filesystem in unprivileged LXC #179

Closed

Description

@Theroxenes

Info:
Running in Debian 13 unprivileged LXC container.

Reproduction steps:

  1. Create an unprivileged LXC container with a directory bind-mounted from your host.
  2. Install Docker on the LXC.
  3. Pull the adibhanna/zennotes image (latest as of 6/14/26 in my case)
  4. Run the zennotes Docker image with the /workspace directory set to somewhere in the directory bind-mounted from the host in step 1.

Result:
The docker image partially hangs, serving the webpage but not responding to docker kill, kill -9 <PID>, or anything short of restarting the docker daemon or LXC host itself. The bound volume on the host is also locked while zennotes is running in this state.

Expected result:
The container starts cleanly, or exits with a non-zero status and a clear error message, or degrades gracefully without locking the filesystem.

Suspected issue:
The hang appears to originate in apps/server/watcher/watcher.go. fsnotify.NewWatcher() or the subsequent fsw.Add() calls in Start() block indefinitely rather than returning an error under unprivileged LXC, where inotify is restricted. Errors from fsw.Add() are currently discarded (_ = fsw.Add(path)), so even a non-blocking failure would be silent. A graceful fallback to polling or a no-op watcher should resolve this issue.

Activity

  1. added
    bug
    on Jun 15, 2026
  2. adibhanna commented on Jun 16, 2026

    @adibhanna
    Contributor

    Fixed in cbbbe76 (on release/v2.4.0, shipping in 2.4.0). Your diagnosis was spot on — pointing at watcher.go, the discarded _ = fsw.Add(path) errors, and the no-op-watcher suggestion made this straightforward.

    I can't reproduce a kernel-level D-state hang outside an unprivileged LXC, so rather than guess at the inotify internals I implemented the graceful degradation you proposed, plus made the watcher non-fatal and gave the silent failures a voice:

    • ZENNOTES_DISABLE_WATCHER=1 → a true no-op watcher: no fsnotify.NewWatcher, no fsw.Add, no tree walk. The vault is still fully served; you only lose live auto-refresh. Because it never makes the inotify syscalls, it sidesteps the wedge entirely — the container stays killable and the bind-mount won't lock. This is the recommended setting for unprivileged LXC.
    • Never fatal: if the watcher can't start it now logs a warning and falls back to the no-op watcher instead of log.Fatal, so the server always comes up.
    • Surfaced errors: the initial walk now counts and logs fsw.Add failures (pointing you at the env var), and watching a newly created directory logs on error too.

    Documented the variable and a "container hangs and won't stop" troubleshooting entry in the Docker how-to.

    If you get a chance to try ZENNOTES_DISABLE_WATCHER=1 on your LXC setup, I'd love to confirm it resolves the hang for you. A polling-based watcher (so live updates still work without inotify) is a reasonable future enhancement if there's demand. Thanks again for the thorough report. 🙏

  3. added a commit that references this issue on Jun 19, 2026
  4. Theroxenes commented on Jun 20, 2026

    @Theroxenes
    Author

    If you get a chance to try ZENNOTES_DISABLE_WATCHER=1 on your LXC setup, I'd love to confirm it resolves the hang for you. A polling-based watcher (so live updates still work without inotify) is a reasonable future enhancement if there's demand. Thanks again for the thorough report. 🙏

    Thanks for the quick fix. The ZENNOTES_DISABLE_WATCHER=1 env var seems to have resolved the startup hanging, I'll give this version a try and see if any other issues surface!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions