How do I set the server to 0.0.0.0 for deployment using Docker

Hi Streamlit

This is truly awesome.

I would like to deploy an application using docker. In order to access the streamlit server outside the container it should be running on 0.0.0.0 (as far as I now). How do I do that?

I’ve tried playing around with the config.toml file without luck.

If I was running a flask web app with gunicorn the entrypoint would be something like

gunicorn app:SERVER --bind 0.0.0.0:8501 --workers 4

How do I run the similar command for streamlit?

At the moment the output inside the container is

  Welcome to Streamlit!

  If you are one of our development partners or are interested in
  getting personal technical support, please enter your email address
  below. Otherwise, you may leave the field blank.

  Email: 

  Telemetry: As an open source project, we collect usage statistics.
  We cannot see and do not store information contained in Streamlit apps.

  If you'd like to opt out, add the following to ~/.streamlit/config.toml,
  creating that file if necessary:

    [browser]
    gatherUsageStats = false


  You can now view your Streamlit app in your browser.

  Network URL: http://172.17.0.2:8501
  External URL: http://2.105.106.214:8501

Thanks.

1 Like

Problem solved. I copied a config.toml file to ~/.streamlit/config.toml during the docker build

with

headless=True
serverAddress = “0.0.0.0”

2 Likes

Hi Marc

Can you elaborate on what you did? I am running a jupyter notebook from a docker container where I have installed streamlit. Do I have to modify the Dockerfile with someting specific to streamilt?

Thanks

Hi @sanjoy

Well, in your docker file you need to

  1. Run your app using streamlit streamlit run app.py or similar.
  2. Make sure your ~/.streamlit/config.toml has the right configurations.
  3. Make sure your ~/.streamlit/credentials.toml has email=""

You can take look at the repo

and start by taking a look at the docker files

and config files

If you like the repo please star it at that gives me energy to improve it.

Thanks.

hi @Marc, thanks a lot for sharing the Dockerfiles. I’m wondering if you have had any luck getting hot realoading to work? I’ve tried mounting the folder where an example app.py file is located but unfortunately I have not yet gotten hot reloading to work the same as when i’m using streamlit run app.py. If I reload the streamlit app manually it does pick up changes that occurred in the mounted app.py file, but it would be great to get the same hot reloading functionality.

1 Like

Hi @tblazina

I actually use the Docker containers for deployment only. So I don’t need hotreloading.

Hi @Marc, Ah alright, I’ll see if I can figure a way around this, or just develop with the normal app and use Docker only for production as you are doing. Cheers!