4

I've been trying to create an docker image to run fbprohet and streamlit. When i run the docker run command i get the below error.

I've stuck on this issue for a number of days now. Any help would be appreciated.

Thanks,

$ docker run <image-id> streamlit hello
Generate machine-id
Traceback (most recent call last):
  File "/usr/local/bin/streamlit", line 5, in <module>
    from streamlit.cli import main
  File "/usr/local/lib/python3.7/site-packages/streamlit/__init__.py", line 74, in <module>
    subprocess.run(["sudo", "dbus-uuidgen", "--ensure"])
  File "/usr/local/lib/python3.7/subprocess.py", line 488, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'sudo': 'sudo'

Dockerfile below

FROM python:3.7-alpine

WORKDIR /workspace

COPY requirements.txt .

RUN apk add --no-cache python3 python3-dev build-base libffi-dev openssl-dev curl krb5-dev linux-headers zeromq-dev jpeg-dev zlib-dev && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install --upgrade pip setuptools && \
    if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
    if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
    rm -r /root/.cache


RUN apk --update add --no-cache gcc freetype-dev libpng-dev

RUN apk add --no-cache --virtual .build-deps \
    musl-dev \
    g++


RUN pip install -r requirements.txt --no-cache-dir 

# removing dependencies
RUN apk del .build-deps


EXPOSE 9999
zafar alam
  • 41
  • 1
  • 5
  • `subprocess.run(["sudo", "dbus-uuidgen", "--ensure"])` presumably requires `shell=True` to work, and is OS-specific. This looks like a problem with streamlit, which you should bring up with the developers. We are not tech support for their project. – Karl Knechtel May 18 '20 at 13:52
  • Thaks @KarlKnechtel I'll raise it as an issue with the streamlit team. – zafar alam May 18 '20 at 14:04
  • @zafaralam we just released a Docker walkthrough here that includes an example Dockerfile: https://docs.streamlit.io/knowledge-base/tutorials/deploy/docker – Caroline Frasca Aug 26 '22 at 17:09

1 Answers1

0

From the error message and your Dockerfile, it appears that Streamlit assumes sudo is available when running. Try adding sudo to your apk add statement.

Randy Zwitch
  • 1,994
  • 1
  • 11
  • 19
  • Adding `sudo` into a dockerfile is a bad practice. Upgrade streamlit to use a version that does not use `sudo` – BeGreen Jun 07 '22 at 09:01
  • Yes, but at the time the comment was written, that was not a choice. Since then, Streamlit has removed the requirement of using sudo as part of the installation. – Randy Zwitch Jun 07 '22 at 12:36
  • Sure, it's for any other dev that come accross this issue. Since dev from my company asked me to add `sudo` from you comment. – BeGreen Jun 07 '22 at 15:40