Streamlit + docker not working

Hi,
I´m trying to dockerize an app made with streamlit but I´ve tried for four days so far and nothing has worked for me.
It takes ages to build the image and when I try to run it, it returns: /bin/sh: 1: streamlit: not found .
This is my docker file (This is my first time using docker )

FROM continuumio/miniconda3

ENV LC_ALL=C.UTF-8

ENV LANG=C.UTF-8

RUN mkdir -p /root/.streamlit

RUN bash -c 'echo -e "\

WORKDIR /ModelosComercio

EXPOSE 8501

ADD environment.yml .

RUN conda env create --file environment.yml

CMD streamlit run ModelosStreamlit.py

Any help will be apreciated.

Thanks

Hi @Maria_Isabel_Meneses,

Thanks for posting!

Have you checked out our new doc on deploying with Docker?

Caroline :balloon:

Not actually but I´m working with conda. Would it be the same if instead of “environment.yml” I try to install “requirements.txt” with pip?
I´ve tried with pip and I get the same error so I don´t really know how to handle this pip/conda thing

I´ve just follow the new doc and I get this error when I try to do it with my project: docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: “streamlit”: executable file not found in $PATH: unknown.

What can I do?

Have you tried following the doc (i.e. using the exact Dockerfile and docker run command in the doc and using pip and requirements.txt instead of conda?

Yes, I´ve tried with pip and requirements.txt. Same result

I’m at a loss as I’m unable to reproduce the behavior. I’ll defer to the rest of the community for solutions :sweat_smile:

The problem is that it can’t find the streamlit executable. In the case of installing streamlit with conda, the streamlit executable will be in miniconda3/bin/streamlit

1 Like

@Dynamo-github
Welcome to the community.
Please give us some more details about your specific problem or share a link to a public github repository so we can take a look.

Hi all, I got the same error with a warning message: add the directory root/.local/bin to the path, ‘/root/.local/bin’ which is not on PATH..

I added
ENV PATH=“${PATH}:/root/.local/bin” to the Dockerfile and I was able to run streamlit from within the docker file successfully.

I am not able to keep the docker container with my streamlit app running. The example works fine, but when I pull data using snowflake.connector, the container closes as soon as the query completes (and before all the other stuff I have in my app).
in Dockerfile:
FROM python:3.9-slim
in requirements.txt:
snowflake-connector-python~=2.7.2

I tried putting a decorator above the function to pull the data (@st.experimental_memo(persist=True))
I tried ChatGPT’s idea to add a while True: sleep(1) at the end of the script.

Any other suggestions?

Hi @Maria_Isabel_Meneses
Please check out the latest docs regarding Streamlit + Docker connection

Hope it will help you to solve your problem

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