FROM python:3.7.3
WORKDIR /app
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install streamlit
COPY . /app
EXPOSE 8501
CMD ["streamlit", "run", "app.py"]
and on running the docker image: docker run -d -p 8051:8080 --name app firstimage:v1
I get a message in the logs of the container:
Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.
You can now view your Streamlit app in your browser.
URL: http://0.0.0.0:8501
On accessing the URL through my browser, I get timed out after a while. Do you know how to fix this?
It seems like you are facing connectivity issues when trying to access your Streamlit app running inside a Docker container. Here are a few things you can check and try to resolve the issue:
Port Mapping:
In your docker run command, you have -p 8051:8080, which maps port 8080 from the container to port 8051 on the host. However, your Streamlit app is running on port 8501 inside the container (CMD [“streamlit”, “run”, “app.py”]). Ensure that you are mapping the correct port.
Update your docker run command to:
docker run -d -p 8501:8501 --name app firstimage:v1
This will map port 8501 from the container to port 8501 on the host.
Check Firewall Settings:
Make sure that there are no firewall restrictions preventing external access to port 8501 on your host machine. Adjust your firewall settings if needed.
Binding to All Network Interfaces:
By default, Streamlit binds to localhost (0.0.0.0) inside the Docker container. This should allow external access. However, you might want to explicitly specify the host when running the Streamlit app:
Update your CMD in the Dockerfile to:
Check the logs of your Docker container to see if there are any error messages or issues reported. You can use the following command to view container logs:
bash
docker logs app
Replace “app” with the actual name of your running container.
Docker Container IP:
In some cases, you might need to use the IP address of the Docker container instead of 0.0.0.0 when accessing the app. You can find the container’s IP address using:
Replace “app” with the actual name of your running container.
After making these adjustments, try accessing your Streamlit app using the correct URL (http://localhost:8501) or (http://<container_ip>:8501) in your browser. If the issue persists, check the logs for any error messages that might provide more information about the problem.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.