Skip to content
Advertisement

Streamlit showing me “Welcome to Streamlit” message when executing it with Docker

I’m trying to run a Docker container created from this Dockerfile

FROM selenium/standalone-chrome
WORKDIR /app

# Install dependencies
USER root
RUN apt-get update && apt-get install python3-distutils -y
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3 get-pip.py

COPY requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
RUN pip install selenium==4.1

# Copy src contents
COPY /src /app/

# Expose the port
EXPOSE 8501

# Execution
ENTRYPOINT [ "streamlit", "run" ]
CMD ["app.py"]

Building this container is possible, but when I execute the image, I obtain the following message:

👋 Welcome to Streamlit!

  If you're one of our development partners or you're interested in getting
  personal technical support or Streamlit updates, please enter your email
  address below. Otherwise, you may leave the field blank.

  Email: 2022-06-06 09:20:27.690 

And, therefore, I am not able to press enter and continue the execution, as the execution halts. Do you guys know how should I make my Dockerfile to directly execute the streamlit run command and surpass this problem?

Advertisement

Answer

That welcome message is displayed when there does not exist a ~/.streamlit/credentials.toml file with the following content:

[general]
email=""

You can either create the above file (.streamlit/credentials.toml) within your app directory and copy its content to the container image in your Dockerfile or create this file using RUN commands on the following:

mkdir -p ~/.streamlit/
echo "[general]"  > ~/.streamlit/credentials.toml
echo "email = """  >> ~/.streamlit/credentials.toml

I would suggest the former approach to reduce the number of layers and thereby reduce the final image size.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement