Watchdog error when running streamlit in docker

I get the following error when running streamlit in Docker. Any ideas?

Traceback (most recent call last):
  File "/usr/local/bin/streamlit", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/streamlit/cli.py", line 205, in main_run
    _main_run(target, args, flag_options=kwargs)
  File "/usr/local/lib/python3.10/site-packages/streamlit/cli.py", line 240, in _main_run
    bootstrap.run(file, command_line, args, flag_options)
  File "/usr/local/lib/python3.10/site-packages/streamlit/bootstrap.py", line 362, in run
    _install_pages_watcher(main_script_path)
  File "/usr/local/lib/python3.10/site-packages/streamlit/bootstrap.py", line 338, in _install_pages_watcher
    watch_dir(
  File "/usr/local/lib/python3.10/site-packages/streamlit/watcher/path_watcher.py", line 154, in watch_dir
    return _watch_path(
  File "/usr/local/lib/python3.10/site-packages/streamlit/watcher/path_watcher.py", line 129, in _watch_path
    watcher_class(
  File "/usr/local/lib/python3.10/site-packages/streamlit/watcher/event_based_path_watcher.py", line 92, in __init__
    path_watcher.watch_path(
  File "/usr/local/lib/python3.10/site-packages/streamlit/watcher/event_based_path_watcher.py", line 170, in watch_path
    folder_handler.watch = self._observer.schedule(
  File "/usr/local/lib/python3.10/site-packages/watchdog/observers/api.py", line 302, in schedule
    emitter.start()
  File "/usr/local/lib/python3.10/site-packages/watchdog/utils/__init__.py", line 93, in start
    self.on_thread_start()
  File "/usr/local/lib/python3.10/site-packages/watchdog/observers/inotify.py", line 118, in on_thread_start
    self._inotify = InotifyBuffer(path, self.watch.is_recursive)
  File "/usr/local/lib/python3.10/site-packages/watchdog/observers/inotify_buffer.py", line 35, in __init__
    self._inotify = Inotify(path, recursive)
  File "/usr/local/lib/python3.10/site-packages/watchdog/observers/inotify_c.py", line 167, in __init__
    self._add_dir_watch(path, recursive, event_mask)
  File "/usr/local/lib/python3.10/site-packages/watchdog/observers/inotify_c.py", line 372, in _add_dir_watch
    self._add_watch(full_path, mask)
  File "/usr/local/lib/python3.10/site-packages/watchdog/observers/inotify_c.py", line 386, in _add_watch
    Inotify._raise_error()
  File "/usr/local/lib/python3.10/site-packages/watchdog/observers/inotify_c.py", line 406, in _raise_error
    raise OSError(err, os.strerror(err))
FileNotFoundError: [Errno 2] No such file or directory
ted with code 1

The Dockerfile:

FROM python:3.10

COPY requirements.txt .

RUN pip install -r requirements.txt

COPY main.py .

EXPOSE 8501

CMD [ "streamlit", "run", "main.py"]

The main.py file:

import streamlit as st

st.write("test")

The requirements.txt:

streamlit >= 1.10.0

Important:

  • Running the streamlit run main.py command locally (not inside Docker) works perfectly fine.
  • Running streamlit hello inside Docker does also work without any problems.
  • I tried different python versions (3.6, 3.8, 3.9) none of them worked, same with lower streamlit versions
2 Likes

I haven’t seen this error yet, and i use docker quite often for local testing of streamlit apps, before deploying them on streamlit cloud. :thinking:
I use python:3.7-slim and python:3.8-slim and python:3.9-slim as base images.

Can you share a link to your public github repo?

Hey, thanks for the response. Unfortunately the repository isn’t public at the moment.

Like you I’ve never seen this error before and I’ve also deployed multiple dashboard via docker before, but on different systems (which should be more or less irrelevant thanks to docker).

When I run the container on my home server I get the same error, so I think it’s not related to the system

Don’t ask me why, but adding WORKDIR /src/app to my Dockerfile and adjusting the paths for COPY and the volumes did the trick.

2 Likes

All this is documented here:

It’s definately a regression from 1.09->1.10, but the pages does note the “workdir” workaournd.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.