How to run streamlit through docker?

Viewed 1194

I want to run the streamlit through docker. I did not find any official image. Can someone please guide me with the steps required to achieve this or Dockerimage for streamlit?

Here is the details

Operating System: Windows 10 Home 

Docker version 19.03.1

Streamlit, version 0.61.0
2 Answers

You can look into this docker hub image.

docker run -it -p 80:80 --entrypoint "streamlit" marcskovmadsen/awesome-streamlit:latest run app.py

Not sure about the streamlit version but you can create one base on this Dockerfile.

Or you can explore streamlit-docker, working for me on my local system.

Quick Setup (own image)

Dockerfile

# Nicked from: https://github.com/markdouthwaite/streamlit-project/blob/master/Dockerfile
FROM python:3.8.4-slim

RUN pip install -U pip

COPY requirements.txt app/requirements.txt
RUN pip install -r app/requirements.txt

# copy into a directory of its own (so it isn't in the toplevel dir)
COPY . /app
WORKDIR /app

CMD ["python", "-m", "streamlit.cli", "run", "main.py", "--server.port=8080"]
EXPOSE 8080

requirements.txt

Then, in the same directory, example contents of the requirements.txt file:

streamlit==0.76.0
pandas==1.2.1
numpy==1.19.5

docker-compose.yml

In a directory above your Dockerfile and source code, you can add:

version: "3.7"
services:
    streamlit:
        build:
          context: streamlit/
        volumes:
          - ./streamlit:/app
        ports:
          - 8080:8080
Related