How to run a containerized streamlit app in a headless/noninteractive mode?
Asked Answered
E

1

5

Streamlit server (run e.g. with streamlit run app-name.py) upon first run for each user requires interaction from her - accepting or rejecting this intro message:

  Welcome to Streamlit!

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

  Email:

Streamlit then waits for input, failing to daemonize (run in background), which quickly causes docker containers in Kubernetes or Openshift to crash (enter the famous crash-loop back off procedure).

How to avoid such crashing, by running Streamlit in headless/noninteractive mode?

Explicate answered 25/4, 2022 at 14:8 Comment(0)
T
8

In the streamlit documentation you can find a detailed list of configurable options. Scroll down and you will find the headless option. Just edit the config file.

headless = true

Please also refer to this post.

Tades answered 25/4, 2022 at 14:16 Comment(2)
Excellent! As seen from your 2nd link, Streamlit is so versatile, that it does not even require shipping a custom config file inside the container. You can do it with an env var (STREAMLIT_SERVER_HEADLESS=true) or a parameter passed to the server (streamlit run your_app.py --server.headless true).Explicate
I'm still getting You can now view your Streamlit app in your browser when using the env STREAMLIT_SERVER_HEADLESS like PYTHONPATH=$(pwd) STREAMLIT_SERVER_HEADLESS=true streamlit run scripts/demo/sampling.py --server.headless trueHokusai

© 2022 - 2024 — McMap. All rights reserved.