Deploy a Streamlit app with Docker

Updated

Streamlit is the fastest way to turn a notebook, a model or a dataset into something people can click. Sharing it is the slow part. With Docker, the app you run locally is exactly what your audience gets.

The Dockerfile

FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8501
CMD ["streamlit", "run", "app.py", \
     "--server.port=8501", \
     "--server.address=0.0.0.0", \
     "--server.headless=true"]

--server.address=0.0.0.0 makes Streamlit reachable from outside the container, and --server.headless=true stops it waiting for a browser to open.

Deploy

docker buildx build --platform linux/amd64 \
  -t push.to.appi.sh/<your-push-id>/app:port_8501 \
  --push .

Copy your personal push address from the APPISH Dashboard. When the slot shows Healthy, the app is live at https://<your-slot>.appi.sh. Streamlit's live updates run over WebSockets, which work through the slot's HTTPS address without extra setup.

API keys for AI demos

Do not bake an OpenAI or Anthropic key into the image. Pass it at runtime as an env64_ tag — the value base64url-encoded — and read it with os.environ:

-t push.to.appi.sh/<your-push-id>/app:env64_OPENAI_API_KEY___<base64url-value>

Remember that the demo is public: anyone with the link spends your tokens. Add a simple password check with st.text_input(type="password") or set a spending limit on the key.

Size and memory

A free slot has modest memory, so large models belong behind an API rather than inside the container. Keep the image lean: python:3.12-slim, no build tools in the final image, and only the packages app.py imports. The same Dockerfile works for Gradio — change the command and the port tag.

More guides