jarvis
jarvis

Reputation: 1

external URL not working for streamlit app deployed using docker

I deployed my Streamlit app using docker, and when I run the container on a GCP VM where I did the docker build, it displays a network url and external url but when I try opening the external url, it doesn’t load. It doesn’t seem to be a firewall issue either.
What should I do if I want to use my external url to share the app with others outside my local network.
Please help.

There isn't much on this issue online, network url and localhost url - works just fine, its the external url that I get that doesn't open. I need this to share my streamlit app with others outside my local network.

I am unable to add relevant images here, so the detailed version of the question is in below link - https://discuss.streamlit.io/t/application-doesnt-open-on-network-and-external-url/19568

$ docker run -p 8501:8501 streamlit_app_v1:latest

or

$ docker run -p 8501:8501 <docker_image_id>

the streamlit app works fine locally and using network url - to share with people within the same network i.e. when I run

$streamlit run streamlit_app.py

Upvotes: -1

Views: 3376

Answers (2)

Anil Mohapatra
Anil Mohapatra

Reputation: 1

For me the issue got solved by doing two things.

  1. This is for my ubuntu VM.
  2. i am adding firewall rule on port 8501 to allow connection request to my ubuntu vm.
  3. if above step resolves the issue, if not then we have to dig deeper and check the iptables
  4. Check for testing purpose by flushing the iptables - sudo iptables -F. FYI doing this resolved my issue. now you can add back you required iptable rules as required

Upvotes: 0

Edo Akse
Edo Akse

Reputation: 4391

So this completely depends on whatever hardware and network you're hosting this on.

What the docker run -p 8501:8501 <docker_image_id> does, is that it binds the port 8501 on the host running docker to the port 8501 on the docker container.

But that does not mean that it becomes accessible on the wider internet.

You'll need to set up the network the host is connected to, to forward requests to this port to the IP of the host. If this is a home network, search for [ROUTER MAKE AND MODEL] port forwarding. It's also advised to assign a static IP to the host to make sure your port forwarding always works.

If this is running on a corporate network, contact your sys-admin.

In other words, the network equipment doesn't know what to do with incoming connections to that port until it's told so. Think about what happens when you have 2 hosts on the same network, how would the router know which host to send incoming requests to?

Upvotes: 0

Related Questions