Windows docker container with basic streamlit application exits automatically after start

Hi this is my python application app.py:

import streamlit as st
st.title(“My Simple Streamlit App”)
st.write(“Hello, world!”)

This is my Dockerfile:

FROM python:3.9.12
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [“streamlit”, “run”, “app.py”, “–server.port=8501”, “–server.address=0.0.0.0”]

This is my requirements.txt:

streamlit

I create the image with:

docker build -t example .

I create the Container with:

docker run -d -p 8501:8501 --name example_container example

Container gets greated and runs but after 3-4 seconds it exits automatically.
On Linux Containers works fine.

PD: docker log:

>Welcome to Streamlit!

  >If you’d like to receive helpful onboarding emails, news, offers, promotions,
  >and the occasional swag, please enter your email address below. Otherwise,
  >leave this field blank.

  >Email:

Any idea?
Thanks!

2 Likes

I have exactly the same problem on Windows. I haven’t been able to try on Linux unfortunately.

Adding

[server]
headless = true

to my config.toml fixed it!

1 Like

…or add --server.headless=true to the docker CMD