I have a basic streamlit code that I want to run using a dockerfile:
app.py
# app.py
import streamlit as st
def main():
st.title("Basic Streamlit App")
# Add some text
st.write("This is a simple Streamlit app.")
# Add a slider widget
number = st.slider("Select a number", 1, 100, 50)
# Display the selected number
st.write("You selected:", number)
# Add a button
if st.button("Click me"):
st.write("Button clicked!")
# Add a checkbox
checkbox_state = st.checkbox("Check me")
st.write("Checkbox state:", checkbox_state)
# Add a selectbox
options = ["Option 1", "Option 2", "Option 3"]
selected_option = st.selectbox("Select an option", options)
st.write("You selected:", selected_option)
if __name__ == "__main__":
main()
Dockerfile
FROM python:3.7
WORKDIR /app
COPY . .
RUN pip3 install -r requirements.txt
EXPOSE 8501
CMD ["streamlit", "run", "app.py", "–server.port=8501", "–server.address=0.0.0.0"]
requirements.txt
streamlit
I run the following commands:
docker build -t streamlit-docker:0.0.1.RELEASE .
docker run -p 8501:8501 streamlit-docker:0.0.1.RELEASE
Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.
You can now view your Streamlit app in your browser.
Network URL: http://172.17.0.4:8501
When I open the URL, the page does not load and returns: This site can’t be reached
I just started with Docker and want to understand where I am going wrong. I tried looking at https://docs.streamlit.io/knowledge-base/tutorials/deploy/docker as well.
EDIT: It works on Mozilla Firefox(122.0.1), but for some reason it does not work when I open the link using Chrome (Version 121.0.6167.184 (Official Build) (arm64))